timshadel (owner)

Fork Of

Revisions

gist: 54231 Download_button fork
public
Description:
Bold your current git branch on the command line (tested on Mac OS X)
Public Clone URL: git://gist.github.com/54231.git
Embed All Files: show embed
.bashrc #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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\] $ "