Closed aidandeli closed 7 months ago
I have the same issue on ubuntu 22.04 but running eval "$(zoxide init bash)"
again doesn't solve the issue here, the db file only grows if i call zoxide add .
in the directory
user@host:~>zoxide --version; fzf --version; alias cd;mkdir /tmp/new_dir;stat --printf="%s\n" ~/.local/share/zoxide/db.zo; cd /tmp/new_dir; cd; stat --printf="%s\n" ~/.local/share/zoxide/db.zo
zoxide 0.9.4
0.46.1 (3c0a630)
alias cd='z'
165
165
It's possible something else is overriding the prompt. Could you try making zoxide init
the last line in your shell config?
Note: This is only usefull for my setup since i wanna use the history command in a non default way. So this might only be helpfull for users that also change the bash environment variable PROMPT_COMMAND on their system
For me, with my history -a
addon, it helped setting the PROMPT_COMMAND to:
PROMPT_COMMAND="history -a ; __zoxide_hook;${PROMPT_COMMAND#;}"
Now the db file increases after using cd to a new dir
eval "$(zoxide init --cmd cd bash)"
is the last line in my config file.
I added the line @kringalf mentioned but I'm still having no luck.
@aidandeli what's the output of echo "$PROMPT_COMMAND"
? It should contain __zoxide_hook
, otherwise something is overriding your prompt.
Ah yeah, the output was just echo
Adding export PROMPT_COMMAND="__zoxide_hook;echo"
after zoxide init
in my config file fixed it.
Ah yeah, the output was just
echo
That typically means something is running after zoxide init
and overriding your PROMPT_COMMAND
. You can use set -x
in your .bashrc
to debug this.
It might be a good idea to mention PROMPT_COMMAND in the documentation somewhere, as the reason why zoxide should be last. I set that variable in my bash config as well, and until @kringalf mentioned it in his comment, I didn't notice the order.
WSL2, kali linux version 2023.3, zoxide version 0.9.3
I installed via the install script. Whenever I navigate anywhere after first opening a terminal window, I noticed the zoxide database doesn't create entries unless I run
eval "$(zoxide init --cmd cd bash)"
again. My.bashrc
does have that line, yes.I can confirm that zoxide is working, as you can see at the second and third prompts in the image.
If we were to move to a brand new directory, we'd assume zoxide would add the new path to db.zo. However, if you look at the image below, you can see that zoxide doesn't update db.zo.
Observe that, after I run
eval "$(zoxide init --cmd cd bash)"
again, that zoxide starts tracking the directories I go to, and the db file grows.