ajeetdsouza/zoxide

`cd` adds all browsed directories to the database

xfzv opened this issue · 2 comments

xfzv commented

I'm using Zsh. Every time I change directory without invoking any zoxide command, said directory is automatically added to the zoxide database. I can see it listed with either % zi or % zoxide edit

This occurs with:

% cd /path/to/dir
% /path/to/dir    # I'm using `setopt AUTO_CD`

Note that z /path/to/dir or zi /path/to/dir also add selected directory to the database, as expected.

% cat /etc/os-release
NAME=Gentoo
ID=gentoo
PRETTY_NAME="Gentoo Linux"
ANSI_COLOR="1;32"
HOME_URL="https://www.gentoo.org/"
SUPPORT_URL="https://www.gentoo.org/support/"
BUG_REPORT_URL="https://bugs.gentoo.org/"
VERSION_ID="2.14"

% zsh --version
zsh 5.9

% zoxide --version
zoxide 0.9.4

% which zoxide
/usr/bin/zoxide

% which z
z () {
	__zoxide_z "$@"
}

% which zi
zi () {
	__zoxide_zi "$@"
}

% echo $_ZO_DATA_DIR
/home/xfzv/.local/share/zsh/zoxide/

% ls $_ZO_DATA_DIR
db.zo

% which cd
cd: shell built-in command

% type cd
cd is a shell builtin

zoxide is loaded at the very end of my .zshrc:

export _ZO_DATA_DIR="$XDG_DATA_HOME/zsh/zoxide/"
eval "$(zoxide init zsh)"

I tried with with 0.9.3, 0.9.2, 0.9.1 and 0.9.0: same behavior. I also tried disabling everything in my .zshrc except these two Zoxide lines but it doesn't make any difference.

Is it an intended behavior? I don't think this used to occur before but maybe I just missed it?

Thanks.

xfzv commented

I'm experiencing the same behavior in a virtual machine (Arch Linux) with zoxide 0.9.4, Zsh 5.9 and even Bash 5.2.26. No additional setting/plug-in whatsoever, just:

# last line of ~/.zshrc
% eval "$(zoxide init zsh)"

# last line of ~/.bashrc
% eval "$(zoxide init bash)"

So I guess this is most likely by design? If so:

  1. (I can't believe I've never noticed this after all these years using zoxide 🥸)
  2. Is there a way to prevent directories passed to cd (or browsed directly thanks to AUTO_CD Zsh option) from being added to the zoxide database?

This is expected behaviour, zoxide automatically adds a hook to your cd command.