-
-
Save timshadel/54231 to your computer and use it in GitHub Desktop.
Bold your current git branch on the command line (tested on Mac OS X)
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
TERM=xterm-color | |
# \[ starts a sequence of non-printable chars | |
# \] ends that sequence | |
# \e[1m turns text that follows Bold | |
# \e[m turns text that follows Normal | |
# | |
# \[\e[1m\] tells the shell not to count the non-printable bold command in it's wrapping calculations | |
# \[\e[m\] tells the shell not to count the non-printable normal command in it's wrapping calculations | |
# | |
# Unlike HTML <b></b> elements; this is more like <b>...<normal> It's important that the shell counts | |
# the characters between <b> and <normal> as printable in its line wrap calculations. | |
parse_git_branch() { | |
git symbolic-ref HEAD 2> /dev/null | cut -d/ -f3- | sed -e 's/\(.*\)/ (\1)/' | |
} | |
PS1="\h:\W\[\e[1m\]\$(parse_git_branch)\[\e[m\] $ " |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment