既然我已经升级到雪豹,如何修复我的 zsh 提示符?

发布于 2024-09-07 20:22:15 字数 591 浏览 2 评论 0原文

我最近将系统升级到雪豹,现在我的提示无法正常工作。我的 .zshrc 文件中有这一行:(

PROMPT='%{$fg_no_bold[cyan]%}%n@%{$fg_no_bold[red]%}%m%{$fg_no_bold[green]%}$(git_branch)%{$reset_color%}: '

其中“git_branch”是一个函数,它为我提供有关我正在处理的当前 git 分支的信息)。问题是颜色和“git_branch”函数没有被评估,它们是按字面意思理解的,所以我的提示是:

%{$fg_no_bold[cyan]%}username@%{$fg_no_bold[red]%}machinename%{$fg_no_bold[green]%}$(git_branch)%{$reset_color%}: 

颜色很好,但我真正想要工作的部分是 git 分支信息。我一直在谷歌搜索,但还没有找到任何东西。当谈到 zsh 时,我有点菜鸟,因此也将不胜感激有用资源的链接。

zsh --version
zsh 4.3.9 (i386-apple-darwin10.0)

I recently upgraded my system to snow leopard and now my prompt doesn't work properly. I have this line in my .zshrc file:

PROMPT='%{$fg_no_bold[cyan]%}%n@%{$fg_no_bold[red]%}%m%{$fg_no_bold[green]%}$(git_branch)%{$reset_color%}: '

(where "git_branch" is a function that give me information about the current git branch I'm working on). The problem is that the colors and "git_branch" function aren't being evaluated, they are taken literally, so my prompt is:

%{$fg_no_bold[cyan]%}username@%{$fg_no_bold[red]%}machinename%{$fg_no_bold[green]%}$(git_branch)%{$reset_color%}: 

The colors are nice, but the part I'd really like to get working is the git branch info. I've been googling, but haven't found anything yet. I'm a bit of a noob when it comes to zsh, so links to helpful resources would also be appreciated.

zsh --version
zsh 4.3.9 (i386-apple-darwin10.0)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

独守阴晴ぅ圆缺 2024-09-14 20:22:15

查看一堆配置文件后,我发现添加这些行:

setopt prompt_subst
autoload colors

colors

导致我的提示再次正确解释我的颜色代码。

After looking at a bunch of config files I discovered that adding these lines:

setopt prompt_subst
autoload colors

colors

caused my prompt to correctly interpret my color codes again.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文