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 load the terminal and start at ~ (the home directory). zsh prompt should read
hostname:username @ user $
cd dev/repo takes me into a git repo, zsh prompt should read
hostname:username @ repo $ (master)
cd .. takes me back to dev, which isn't a git repo, prompt should read
hostname:username @ dev $
The prompt never changes / updates automatically; I have to run source ~/.zshrc to make the prompt update as I change directories.
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!
Figured it out by happenstance a few months later after not really caring... the prompt has to use single quotes instead of double-quotes.
PROMPT='%F{226}%m:%n @ %F{214}%1d %F{226}\$%f ${vcs_info_msg_0_}'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With