我逐渐从 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
中。让它在 future 的终端上工作。我捕获了正确的转义序列 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 .当您升级时,您可能想改用他的机制。
关于macos - 如何让 ZSH 在终端框架中显示当前目录?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11025063/