Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用 oh-my-zsh 并想编写一个小插件,当我切换目录时它会自动执行命令。因此,例如,我将不得不进行某种映射,例如
/Users/ed1t/Dropbox="echo 进入 Dropbox 目录"
我可以编写一个函数 cd() 来执行此操作,但这是有效的方法吗?
我认为您正在寻找chpwd钩子功能。
chpwd
chpwd () { echo "Changing directory from $OLDPWD to $PWD" }