gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 22:49:29 25 4
gpt4 key购买 nike

我逐渐从 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com