macos - 如何让 ZSH 在终端框架中显示当前目录?

标签 macos terminal zsh

我逐渐从 Bash 切换到 ZSH,并尝试通过复制功能来学习。不过好像找不到这个。

Bash does this by default I think

我应该放什么,我应该把它放在哪里?这甚至可能吗?谢谢。

最佳答案

尝试这个:

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/

相关文章:

macos - 我可以让 Safari 应用扩展工具栏按钮的文本徽章不那么难看吗?

python - 在 os x Lion 上运行 python 程序

ubuntu - 终端进程 "/usr/bin/zsh"以退出代码 : 14 终止

bash - Shell 变量定义和替换是否在一行中正确引用?

macos - 如何在 OSX 上注册文档 MIME 类型,以便它出现在浏览器 navigator.MIMETypes 数组中

Mac、Windows 和 Linux 上的 Java 桌面应用程序安装程序

shell - 如何从终端启用文件库

ubuntu 终端中的 java.lang.NoClassDefFoundError

linux - which 命令在 zsh 和 bash 中的不同行为

linux - 为什么 zsh 不会自动完成自定义创建的脚本,而 bash 会自动完成?