Created
September 5, 2024 01:34
-
-
Save wdhowe/726bc72ce086ffeb041f08b4d5964eb6 to your computer and use it in GitHub Desktop.
bash color prompt with git branch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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