How to add git vcs_info to the prompt_bart_setup theme in zsh?

I’m trying to modify the bart theme so it includes git status information. I got it to work, but it doesn’t update when I change directories

I modified the bart theme by enabling vcs_info:

  • Git how to prevent local modification of public commits
  • Utility of staging unmodified files using Git?
  • private-bower behind blocking proxy. what exceptions are needed?
  • Git through svn - managing files
  • How can I split a past un-pushed commit with Sourcetree?
  • Strategy for extracting messages of most useful commits to changelog
  • prompt_bart_setup () {
        # ...
        autoload -Uz vcs_info
        # Set vcs_info parameters.
        zstyle ':vcs_info:*' enable bzr git hg svn
        zstyle ':vcs_info:*' check-for-changes true
        zstyle ':vcs_info:*' stagedstr '%F{green}●%f'
        zstyle ':vcs_info:*' unstagedstr '%F{yellow}●%f'
        zstyle ':vcs_info:*' formats ' - [%b%c%u]'
        zstyle ':vcs_info:*' actionformats " - [%b%c%u|%F{cyan}%a%f]"
        zstyle ':vcs_info:(sv[nk]|bzr):*' branchformat '%b|%F{cyan}%r%f'
        zstyle ':vcs_info:git*+set-message:*' hooks git-status
        # ...
    prompt_bart_precmd () {
        # ...
        # ...

    And populating the RPROMT variable (it also works with PS1, but I wanted to isolate the problem):

    prompt_bart_ps1 () {
        # ...
        # ...

    This works if I create a new terminal session in a git repo, but it doesn’t update when I change directories.

    I’ve seen suggestions to use single quotes, but when I change it to this:

    prompt_bart_ps1 () {
        # ...
        setopt promptsubst
        # ...

    The prompt shows literally ${vcs_info_msg_0_}. Any ideas?

  • Can I move a local Git repository to elsewhere within my hard drive safely?
  • Why is git erroring with 'Assertion failed' on git add .?
  • Git rm, gives scary “Deletion of directory failed” when I only delete one file
  • Git: List all files in a directory across all branches?
  • Un-ignoring a file in an ignored directory in git
  • What is GIT_WORK_TREE, why have I never needed to set this ENV var, why now?
  • One Solution collect form web for “How to add git vcs_info to the prompt_bart_setup theme in zsh?”

    There seems to be a problem with promptsubst. RPROMPT="${vcs_info_msg_0_}" will substitute the value of vcs_info_msg_0_ when RPROMPT is first defined. That is the reason why it works when you open a shell in a repository but not when you change into one.

    The single-quoted variant prevents this initial substitution and setopt promptsubst should then do the substitution everytime the prompt is used. But in your case it doesn’t, obviously. Possibly, there is a setopt nopromptsubst somewhere in your zsh configuration that gets called after the one in prompt_bart_setup.

    See with setopt | grep promptsubst if it is really set.

    Git Baby is a git and github fan, let's start git clone.