Skip to content

Instantly share code, notes, and snippets.

@MauricioRobayo
Last active November 22, 2020 11:35
Show Gist options
  • Save MauricioRobayo/92eadc7dd94ee5dee29038306cc2882e to your computer and use it in GitHub Desktop.
Save MauricioRobayo/92eadc7dd94ee5dee29038306cc2882e to your computer and use it in GitHub Desktop.
Git PS1 using git-prompt.sh
# https://github.com/git/git/blob/master/contrib/completion/git-prompt.sh
[ -s "$HOME/.git-prompt.sh" ] && . "$HOME/.git-prompt.sh"
[ -s "$HOME/.git-completion.bash" ] && . "$HOME/.git-completion.bash"
GIT_PS1_SHOWDIRTYSTATE=1
GIT_PS1_SHOWSTASHSTATE=1
GIT_PS1_SHOWUNTRACKEDFILES=1
GIT_PS1_SHOWCOLORHINTS=1
GIT_PS1_SHOWUPSTREAM="auto"
GIT_PS1_DESCRIBE_STYLE="default"
exitstatus() {
[ $? -ne 0 ] && echo -e "\e[1;31mE!\e[0m"
}
ps1_pre+='$(exitstatus)[\W]'
ps1_post='\$ '
PROMPT_COMMAND="__git_ps1 '${ps1_pre}' '${ps1_post}' '(%s)'"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment