Directly cd in $HOME when no arguments passed
Closed this issue · 2 comments
I wanted to replace cd with z, but there this feature in cd that when no arguments are passed, it changes directory to the home one. z instead will display the list of directories in the database. How can I obtain the same behaviour of cd in z?
Cd behaviour
~/Documents/work
-> cd
~
->
z behaviour
~/Documents/work
-> z
...
~/Documents/work
->
z configuration
I use the zsh
ZSHZ_CMD
= cd
ZSHZ_DATA
= '~/.z'
ZSHZ_TAILING_SLASH
= 1
For completion:
setopt COMPLETE_ALIASES
compdef _zsh ${ZSHZ_CMD:-${_Z_CMD:-z}}
I would not recommend using cd
to invoke Zsh-z, as the commands do very different things -- cd
takes very specific instructions and no guesswork is involved, whereas Zsh-z takes vague and abbreviated instructions and a fair amount of guesswork is involved. The two commands also have very different command-line options. One is not a drop-in replacement for the other.
That said, if you really want to change Zsh-z's behavior so that typing merely z
takes you to $HOME
, you could add in your .zshrc
, underneath where you load or source Zsh-z, something like
unalias z
z() { [[ -z $* ]] && cd || zshz $@ 2>&1; }
Thanks.