I'm just trying to show the current branch of the git repository I'm inside (if available) by using vcs_info
. The relevant portion of my .zshrc
file is as follows:
autoload -Uz vcs_info
zstyle ':vcs_info:*' enable git
zstyle ':vcs_info:*' formats "%F{010}(%b)%f "
precmd() { vcs_info }
setopt prompt_subst
PROMPT="%F{226}%m:%n @ %F{214}%1d %F{226}\$%f ${vcs_info_msg_0_}"
I expect:
I load the terminal and start at
~
(the home directory). zsh prompt should readhostname:username @ user $
cd dev/repo
takes me into a git repo, zsh prompt should readhostname:username @ repo $ (master)
cd ..
takes me back todev
, which isn't a git repo, prompt should readhostname:username @ dev $
I experience:
The prompt never changes / updates automatically; I have to run source ~/.zshrc
to make the prompt update as I change directories.
What I have tried:
I've tried updating the precmd()
block to be as follows:
precmd() {
vcs_info
echo "This has been executed"
}
And I see This has been executed
right before every prompt, so I know that the precmd block is being entered correctly. It seems that the vcs_info
just isn't working.
Perhaps I'm missing something; can someone point out what the issue could be? Thanks!
precmd
method – Ichang