输入目录时在zsh中输入文件

Dav*_*man 4 environment zsh

有没有办法在输入特定目录时获取特定文件来设置环境?有点像rvm,但更一般.

Fra*_*sco 15

恕我直言你不应该使用别名,但添加一个钩子到任何目录更改:

autoload -U add-zsh-hook
load-local-conf() {
     # check file exists, is regular file and is readable:
     if [[ -f .source_me && -r .source_me ]]; then
       source .source_me
     fi
}
add-zsh-hook chpwd load-local-conf
Run Code Online (Sandbox Code Playgroud)

这个钩子函数将在任何目录更改时运行.

FWIW,如果你想改变dirs 而不是试探钩子,请使用cd -q dirname