Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

zsh not updating vcs_info

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:

  1. I load the terminal and start at ~ (the home directory). zsh prompt should read

    hostname:username @ user $

  2. cd dev/repo takes me into a git repo, zsh prompt should read

    hostname:username @ repo $ (master)

  3. cd .. takes me back to dev, which isn't a git repo, prompt should read

    hostname: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!

like image 336
Mephoros Avatar asked Jun 04 '19 18:06

Mephoros


1 Answers

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_}'

like image 156
Mephoros Avatar answered Sep 19 '22 12:09

Mephoros