Created
November 24, 2019 06:15
-
-
Save gregw/6408bcb746fa8dcebf03ecb7bcecabf5 to your computer and use it in GitHub Desktop.
bash git prompt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# set a fancy prompt | |
__gitps1 () { | |
local b="$(__git_ps1)" | |
if [ -n "$b" ] | |
then | |
local c=$(git log @{u}.. --oneline 2>/dev/null | wc -l) | |
if [ "$c" -gt 0 ] | |
then | |
printf "%s^%d" "${b##refs/heads/}" "$c" | |
else | |
local c=$(git log ..@{u} --oneline 2>/dev/null | wc -l) | |
if [ "$c" -gt 0 ] | |
then | |
printf "%sv%d" "${b##refs/heads/}" "$c" | |
else | |
printf "%s" "${b##refs/heads/}" | |
fi | |
fi | |
fi | |
} | |
#PS1='\n\u@\h: \w$(__gitps1 "(%s)")\n[\!] ' | |
PS1='\n\[\033[01;34m\]\u@\h\[\033[00m\]: \w$(__gitps1 "(%s)")\n[\!] ' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment