Append git-branch name in command line
if you are using your command line as login shell , you have to edit your ~/.bash_profile file, else edit ~/.bashrc , and add following lines
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
PS1="\[\033[36m\]\u${debian_chroot:+($debian_chroot)}\w\[\033[33m\]\$(parse_git_branch)\[\033[00m\]\$(git config user.initials)$\[\033[00m\] "
Demo:
if you are editing ~./.bash_profile file you have to add these lines before those..
if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi
Written by Mohamed Rashid
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Cli
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#