我正逐渐从
Bash切换到ZSH,并尝试通过复制功能来学习.似乎无法找到这一个.
我应该放什么,我应该把它放在哪里?这甚至可能吗?谢谢.
解决方法
试试这个:
settitle() { printf "\e]0;$@\a" } dir_in_title() { settitle $PWD } chpwd_functions=(dir_in_title)
现在,您的cd命令将运行dir_in_title函数,该函数将打印一个转义序列,要求Terminal.app更新标题. (奇怪的是,使用至少在urxvt中运行的转义序列.这些必须比我预期的更标准化.)
如果您喜欢这种效果,则需要将这些行添加到〜/ .zshrc中,以便在未来的终端上工作.
我抓住了正确的转义序列from Chris Page on superuser和函数样式from my answer to similar but different question. Chris Page gave his own answer on that question with details on OS X 10.7 that are drastically different.当你升级时,你可能会想要使用他的机制.