Skip to content

Instantly share code, notes, and snippets.

@wdhowe
Created September 5, 2024 01:34
Show Gist options
  • Save wdhowe/726bc72ce086ffeb041f08b4d5964eb6 to your computer and use it in GitHub Desktop.
Save wdhowe/726bc72ce086ffeb041f08b4d5964eb6 to your computer and use it in GitHub Desktop.
bash color prompt with git branch
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
# color prompt example: "user@host:~/path(git-branch)$"
PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\[\e[91m\]$(parse_git_branch)\[\e[00m\]\$'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment