Reputation: 14454
I'm trying to modify the bart theme so it includes git status information. I got it to work, but it doesn't update when I change directories
I modified the bart theme by enabling vcs_info:
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
# ...
}
And populating the RPROMT variable (it also works with PS1, but I wanted to isolate the problem):
prompt_bart_ps1 () {
# ...
RPROMPT="${vcs_info_msg_0_}"
# ...
}
This works if I create a new terminal session in a git repo, but it doesn't update when I change directories.
I've seen suggestions to use single quotes, but when I change it to this:
prompt_bart_ps1 () {
# ...
setopt promptsubst
RPROMPT='${vcs_info_msg_0_}'
# ...
}
The prompt shows literally ${vcs_info_msg_0_}
. Any ideas?
Upvotes: 2
Views: 1199
Reputation: 18439
There seems to be a problem with promptsubst
. RPROMPT="${vcs_info_msg_0_}"
will substitute the value of vcs_info_msg_0_
when RPROMPT
is first defined. That is the reason why it works when you open a shell in a repository but not when you change into one.
The single-quoted variant prevents this initial substitution and setopt promptsubst
should then do the substitution everytime the prompt is used. But in your case it doesn't, obviously. Possibly, there is a setopt nopromptsubst
somewhere in your zsh configuration that gets called after the one in prompt_bart_setup
.
See with setopt | grep promptsubst
if it is really set.
Upvotes: 1