I'm currently using zsh
with oh-my-zsh
, and I've run into an annoying shell behaviour.
I must have done a subtle yet breaking change in the $PATH
export while editing my .zshrc
, because the following thing happens:
At the shell prompt while in ~/
, issuing, for example, the flutter
command...
$ flutter
...results in:
$ ~/flutter/
(as if calling $ flutter
had been interpreted as $ cd flutter
)
However, issuing $ flutter
in any other directory, including $ ~/flutter
results in the correct execution of the flutter
command. Same thing for go
and others.
Line 2
on my .zshrc
exports $PATH
in the following fashion:
export PATH=$HOME/bin:$HOME/.emacs.d:$HOME/flutter/bin/cache/dart-sdk:$HOME/flutter/bin/cache/dart-sdk/bin:$HOME/.pub-cache/bin:$HOME/.composer/vendor/bin:$HOME/.cargo/env:$HOME/.platformio/penv/bin:$HOME/flutter/bin:$PATH
I've been comparing .zshrc
versions with other backups, and I may be missing something, but no differences were found.
What seems off, in your opinion?
If you've encountered this annoyance before, how did you correct it?
It'a feature called AUTO_CD
.
AUTO_CD (-J)
If a command is issued that can’t be executed as a normal command, and the command is the name of a directory, perform the cd command to that directory.
http://zsh.sourceforge.net/Doc/Release/Options.html#Changing-Directories
AUTO_CD
is enabled by oh-my-zsh in file oh-my-zsh/lib/theme-and-appearance.zsh
.
...
setopt auto_cd
setopt multios
setopt prompt_subst
[[ -n "$WINDOW" ]] && SCREEN_NO="%B$WINDOW%b " || SCREEN_NO=""
...
Append the following command in ~/.zshrc
after oh-my-zsh
is loaded to disable this feature.
unsetopt AUTO_CD