Skip to content

Instantly share code, notes, and snippets.

@A9u
Created July 7, 2020 07:55
Show Gist options
  • Save A9u/0d9526015bd6bef80303df38006d5cf7 to your computer and use it in GitHub Desktop.
Save A9u/0d9526015bd6bef80303df38006d5cf7 to your computer and use it in GitHub Desktop.
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\[\033[00m\]\[\033[01;34m\]\W\[\033[01;31m\]$(parse_git_branch)\[\033[00m\]'
else
PS1='${debian_chroot:+($debian_chroot)}\W$(parse_git_branch)'
fi
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
PS1="\[\e]0;${debian_chroot:+($debian_chroot)} \W\a\]$PS1"
;;
*)
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment