hstr icon indicating copy to clipboard operation
hstr copied to clipboard

Hstr looks for .zshistory even though HISTFILE is set to something else.

Open kannwism opened this issue 1 year ago • 6 comments

Hi there,

I'm currently trying to switch from bash to zsh. hstr worked perfectly with bash, but I am encountering the following problem with zsh:

just executing hstr (or pressing ctrl+r) give me the error:

marian@marian-ThinkPad-P51:~$ hstr

Unable to read history file from '/home/marian/.zhistory'!

However, HISTFILE is set to .bash_eternal_history, as it is configured in my .zshrc:

marian@marian-ThinkPad-P51:~$ echo $HISTFILE
/home/marian/.bash_eternal_history

Is this a bug or are misconfiguration on my side? I would assume that hstr also looks at the HISTFILE variable.

kannwism avatar Jul 05 '22 09:07 kannwism

Getting the same issue on my setup. For now using symlink as workaround.

Aetherbase avatar Feb 12 '23 07:02 Aetherbase

@Aetherbase @kannwism increasing priority - thank you :pray: I will it in the upcoming release.

dvorka avatar Feb 12 '23 15:02 dvorka

is there any progress or workaround on this issue?

hu-chia avatar Apr 12 '23 08:04 hu-chia

@guyeu @kannwism I tried to repro this issue multiple times, however, it works for me. Please check below what I tried:

  • I created file .bash_eternal_history in my home directory i.e. /home/dvorka/.bash_eternal_history (and stored only 1 entry to that file: "BUG REPRO").
  • I added export HISTFILE=/home/dvorka/.bash_eternal_history to .zshrc.
  • I created brand new shell.
  • I checked that the variable is set using echo $HISTFILE.
  • I ran hstr and it loaded the file specified by $HISTFILE variable w/ the entry.

I will need more details to repro. What's interesting is that you are loading "bash" history in Zsh. Also HSTR uses .zhistory as the last fallback when:

  • Shell is Zsh.
  • HISTFILE variable is NOT defined.
  • /home/$USER/.zsh_history does not exist.

Perhaps the file exist, but its content cannot be loaded. Could you please try:

  • Backup your .bash_eternal_history.
  • Store to .bash_eternal_history only 1 row w/ a simple string like TEST.
  • Create new shell.
  • Run HSTR?

Can you please also share:

  • your Linux distribution and version
  • hstr --version
  • zsh --version

Thanks!

dvorka avatar Apr 15 '23 15:04 dvorka

Hi @dvorka,

thanks for looking into it! I faced the issue on a company Ubuntu laptop, which, unfortunately, I don't have anymore. On my current machine (mac) everything is working fine. Maybe @guyeu has the ability to reproduce the issue at the moment?

kannwism avatar Apr 15 '23 15:04 kannwism

I have this issue before. I set HISTFILE with

HISTFILE="$HOME/.cache/zsh_history"

I found that I missing export. Solve it after adding export

export HISTFILE="$HOME/.cache/zsh_history"

eeeXun avatar Apr 15 '23 16:04 eeeXun