I've been thinking about switching over to zsh and prezto for some time now, but there are some nuisances that I'd like to solve first.
Biggest of these is the fact that it seems like the tab completion for 'cd' is messed up somehow. For instance, I've a directory called "git" in my home directory for my git projects and I frequently want to move to it from the home directory, that is, I write this:
~ >>> cd g[TAB]
~ >>> cd git
Since "git" is the only folder starting with a "g" I obviously expect that to be the result of the tab completion. However, with ZSH and prezto, it instead completes it like this:
~ >>> cd g[TAB]
~ >>> cd gnats
Using tab again will also try to complete a subfolder to "gnats", neither of which exists!
So far I've at figured out that this is most likely caused by prezto, since disabling it reverts back to the expected behavior.
Any ideas what configuration I have to add to fix this?
The most likely culprit is the shell option
CDABLE_VARS
. You can check if it is set withsetopt | grep cdablevars
. As it is not a default setting you can either find where it is set within prezto or explicitly unset it withsetopt nocdablevars
after prezto is sourced.Explanation:
If
CDABLE_VARS
is set, zsh handles arguments tocd
that are not directories and do not begin with/
as if they begin with~
. This extends to the autocompletion forcd
.If a directory name starts with
~
(as is implied byCDABLE_VARS
), zsh checks if the element up to the first/
can be subsituted in a few different ways. In your case,~gnats
is interpreted as static named directory, which may defined by the following means:~someone
is the home directory of the user someone.by setting a shell parameter to a string value which begins with
/
:by using
hash -d
:hash -d SOMEWHERE=/some/directory
I would guess that in this case it is the home directory of the user gnats. Which - as far as I can tell - seems to be created by default on at least Debian and Ubuntu.