【发布时间】:2014-03-01 13:17:28
【问题描述】:
我正在尝试修改bart theme,使其包含 git 状态信息。我让它工作了,但是当我更改目录时它不会更新
我通过启用 vcs_info 修改了 bart 主题:
prompt_bart_setup () {
# ...
autoload -Uz vcs_info
# Set vcs_info parameters.
zstyle ':vcs_info:*' enable bzr git hg svn
zstyle ':vcs_info:*' check-for-changes true
zstyle ':vcs_info:*' stagedstr '%F{green}●%f'
zstyle ':vcs_info:*' unstagedstr '%F{yellow}●%f'
zstyle ':vcs_info:*' formats ' - [%b%c%u]'
zstyle ':vcs_info:*' actionformats " - [%b%c%u|%F{cyan}%a%f]"
zstyle ':vcs_info:(sv[nk]|bzr):*' branchformat '%b|%F{cyan}%r%f'
zstyle ':vcs_info:git*+set-message:*' hooks git-status
# ...
}
prompt_bart_precmd () {
# ...
vcs_info
# ...
}
并填充 RPROMT 变量(它也适用于 PS1,但我想隔离问题):
prompt_bart_ps1 () {
# ...
RPROMPT="${vcs_info_msg_0_}"
# ...
}
如果我在 git repo 中创建一个新的终端会话,这会起作用,但是当我更改目录时它不会更新。
我看到了使用单引号的建议,但是当我将其更改为:
prompt_bart_ps1 () {
# ...
setopt promptsubst
RPROMPT='${vcs_info_msg_0_}'
# ...
}
提示字面意思是${vcs_info_msg_0_}。有什么想法吗?
【问题讨论】: