zsh-git-prompt
zsh-git-prompt copied to clipboard
ZSH git prompt not detecting git changes
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|?) ~࿔
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%}"
}
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
@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!
:+1:
@klaasb Changing to single quotes works for me. Thanks!
+1 for single quote fix
I used it to implement a much simpler color indicator
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'
source ~/dotF/zsh-git-prompt/zshrc.sh
function precmd {
export RPS1='$(git_super_status)'
}