Text 1 Jun Showing git branches in your prompt

It’s simply. You only have to add the following in your /etc/bashrc


# You should have already defined the PS1 variable. You should update it


function parse_git_branch_and_add_brackets { git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\ \[\1\]/' } PS1="\h:\W \u\[\033[0;33m\]\$(parse_git_branch_and_add_brackets) \[\033[0m\]\$ "
Reset terminal and you got it!
P.S.: Be careful with quotes


Design crafted by Prashanth Kamalakanthan. Powered by Tumblr.