Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save victoriadrake/06ccda58e1b34110386b403b0742683a to your computer and use it in GitHub Desktop.
Save victoriadrake/06ccda58e1b34110386b403b0742683a to your computer and use it in GitHub Desktop.

Add the current git branch to your bash prompt! In .bashrc:

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[0;1;38;5;247m\]> \[\033[3;38;5;68m\]\W $(parse_git_branch)\[\033[00m\] '
else
    PS1='${debian_chroot:+($debian_chroot)}\W $(parse_git_branch)\[\033[00m\] '
fi

No more accidentally merging master into your this-seems-like-a-good-idea branch!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment