zsh-git-prompt icon indicating copy to clipboard operation
zsh-git-prompt copied to clipboard

ZSH git prompt not detecting git changes

Open cevaris opened this issue 9 years ago • 8 comments

Also, seems that __CURRENT_GIT_STATUS is not auto updating as well.

To reporoduce

  • I start with a clean git state of master branch.
  • Touch a new file blah
  • See that the git status prompt did not update
  • Re-source my ~/.zshrc file and it picks up the new untracked file
dots (master|✔) ~࿔ git st
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working directory clean
dots (master|✔) ~࿔ touch blah
dots (master|✔) ~࿔ git st
On branch master
Your branch is up-to-date with 'origin/master'.
Untracked files:
  (use "git add <file>..." to include in what will be committed)

        blah

nothing added to commit but untracked files present (use "git add" to track)
dots (master|✔) ~࿔ source ~/.zshrc
dots (master|?) ~࿔

cevaris avatar Mar 05 '15 17:03 cevaris

Fixed by defining a precmd function in my .zshrc file.

source ~/.zsh.d/zsh-git-prompt/zshrc.sh
function precmd {
    PROMPT="%{$fg[green]%}%c $(git_super_status)%{$fg[red]%}~%{$fg[white]%}࿔ %{$reset_color%}"
}

cevaris avatar Mar 05 '15 19:03 cevaris

You can also fix it by using single quotes, so the variables and commands in PROMPT don't get evaluated when sourcing .zshrc. See here: http://unix.stackexchange.com/questions/14266/how-do-you-make-rprompt-in-zsh-update-itself-on-every-enter

klaasb avatar Mar 05 '15 20:03 klaasb

@cevaris That actually seems to have worked. I'll test the rest of today and see if there are any bugs or situations where it doesn't work. Thanks!

zhimsel avatar Mar 05 '15 20:03 zhimsel

:+1:

cevaris avatar Mar 06 '15 01:03 cevaris

@klaasb Changing to single quotes works for me. Thanks!

yibum avatar Feb 15 '16 19:02 yibum

+1 for single quote fix I used it to implement a much simpler color indicator screen shot 2016-04-26 at 9 48 05 am

therealplato avatar Apr 26 '16 13:04 therealplato

Just a note that this single quote thing is valid for all files in the custom/ folder.

This gave me a hard time after having copied over code from my .bash_aliases. Some aliases there defined with double quotes made my git prompt stopped working again.

The following will cause issues

## Recursively delete `.DS_Store` files
alias cleanup="find . -type f -name '*.DS_Store' -ls -delete"

## Kill all the tabs in Chrome to free up memory
# [C] explained: http://www.commandlinefu.com/commands/view/402/exclude-grep-from-your-grepped-output-of-ps-alias-included-in-description
alias chromekill="ps ux | grep '[C]hrome Helper --type=renderer' | grep -v extension-process | tr -s ' ' | cut -d ' ' -f2 | xargs kill"

Had to flip the single and double arrangement: single quote outside, double quote inside

## Recursively delete `.DS_Store` files
alias cleanup='find . -type f -name "*.DS_Store" -ls -delet'

## Kill all the tabs in Chrome to free up memory
# [C] explained: http://www.commandlinefu.com/commands/view/402/exclude-grep-from-your-grepped-output-of-ps-alias-included-in-description
alias chromekill='ps ux | grep "[C]hrome Helper --type=renderer" | grep -v extension-process | tr -s " " | cut -d " " -f2 | xargs kill'

aamnah avatar May 03 '20 10:05 aamnah

source ~/dotF/zsh-git-prompt/zshrc.sh


function precmd {
export RPS1='$(git_super_status)'
}

sisrfeng avatar Jan 10 '22 05:01 sisrfeng