Skip to content

Instantly share code, notes, and snippets.

@yehee
Last active May 26, 2020 22:12
Show Gist options
  • Save yehee/e1445ccb7a70ee4847ddd67738088e07 to your computer and use it in GitHub Desktop.
Save yehee/e1445ccb7a70ee4847ddd67738088e07 to your computer and use it in GitHub Desktop.
Show git branch and short-hand status on terminal command prompt
alias co="cd ~/code"
B="\e[38;5;35m"
C="\e[38;5;50m"
D="\e[38;5;199m"
E="\[\033[00m\]"
b() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
s() {
git status -s 2> /dev/null | ( ! grep ^ ) > /dev/null && printf "$C ✔" || printf "$D ✗"
}
export PS1="\u@\h \W$B\$(b)\$(s)$E "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment