this is my .zshrc file . vcs_info working for single quoted prompt but it's not working for double quoted prompt.
autoload -Uz vcs_info
zstyle ':vcs_info:*' enable git svn
zstyle ':vcs_info:git*' formats "- (%b) "
precmd() {
vcs_info
}
setopt prompt_subst
# prompt='%2/ ${vcs_info_msg_0_}> '
prompt="%2/ ${vcs_info_msg_0_}> "
but this not working.
CodePudding user response:
Inside double quotes, the parameter expansion is expanded immediately, so you are hard-coding the value of ${vcs_info_msg_0_} when the prompt string is defined, rather than the value when the prompt is displayed.
Your options include
Continuing to use single quotes
Escaping the
$:prompt="%2/ \${vcs_info_msg_0_}> "Setting
promptitself insideprecmd, so thatpromptis freshly defined after each update to the VCS information.precmd () { vcs_info prompt="%2/ ${vcs_info_msg_0_}> " }
CodePudding user response:
you just need change your syntax to use vcs_info in double quoted prompts
prompt="%2/"'${vcs_info_msg_0_}>'
or here is another example (parrot os prompt)
prompt="%F{red}┌[%f%F{green}$USER%f%F{yellow}㉿%f%F{cyan}%m%f%F{red}]─[%B%F{magenta}%~%f%F{red}]%f%F{201}"'${vcs_info_msg_0_}'"%f"$'\n'"%F{red}└╼%f%F{yellow}$%f"
