Skip to content

Instantly share code, notes, and snippets.

@gsw945
Created June 20, 2022 09:23
Show Gist options
  • Save gsw945/71842db7ca9fc0bddd4e30bfe57e1d1f to your computer and use it in GitHub Desktop.
Save gsw945/71842db7ca9fc0bddd4e30bfe57e1d1f to your computer and use it in GitHub Desktop.
git show branch in bash
# append to ~/.bashrc
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
export PS1="${PS1:0:-1}\[\033[33m\]\$(parse_git_branch)\[\033[00m\] "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment