Skip to content

Instantly share code, notes, and snippets.

@hadnazzar
Created September 27, 2018 09:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hadnazzar/b494abdfa1e5465786f771651f3a4430 to your computer and use it in GitHub Desktop.
Save hadnazzar/b494abdfa1e5465786f771651f3a4430 to your computer and use it in GitHub Desktop.
Zsh Right Prompt for show github differences (diff --shortstat) in terminal prompt
git_prompt() {
#temp=`git symbolic-ref HEAD 2>/dev/null | cut -d / -f 3`
temp=`git diff --shortstat | sed -e 's/insertions//' -e's/deletions//'`
if [ "$temp" != "" ]; then
RPROMPT='%{$fg_no_bold[green]%}git:($temp%)%{$reset_color%} %{$fg_no_bold[yellow]%}[%1~]%{$reset_color%} %t'
else
RPROMPT='%{$fg_no_bold[yellow]%}[%~]%{$reset_color%} %t'
fi
}
autoload -Uz add-zsh-hook
add-zsh-hook precmd git_prompt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment