Currently in my .zshrc
I have the following lines to provide some git info:
autoload -Uz vcs_info
precmd_vcs_info() { vcs_info }
precmd_functions+=( precmd_vcs_info )
setopt prompt_subst
RPROMPT=\$vcs_info_msg_0_
zstyle ':vcs_info:git:*' formats '%b'
This makes my shell look like the following:
[me@computer dir]$ main
I would like to move this configuration out of .zshrc
and into a custom prompt that is initiliazed using promptinit
. This configuration is in a file called prompt_mycustomprompt_setup
that is available on my fpath
. The configuration looks as follows:
precmd_vcs_info() {
vcs_info
}
prompt_mycustomprompt_setup () {
autoload -Uz add-zsh-hook vcs_info
setopt prompt_subst
add-zsh-hook precmd precmd_vcs_info
RPROMPT=\$vcs_info_msg_0_
zstyle ':vcs_info:git:*' formats '%b'
PS1='(test)> '
}
prompt_mycustomprompt_setup "$@"
I then removed the relevant lines from my .zshrc
and replaced with the following lines:
autoload -Uz promptinit
promptinit
prompt mycustomprompt
However, the vcs_info is not displayed and instead I have a constant static value of $vcs_info_msg_0_
in my prompt:
(test)> $vcs_info_msg_0_
Why will my prompt not behave as expected?