Following will help you to overcome above hassle and have a quick glance at your branch name.
1. Open /home/<USER>/.bashrc file.
2. Add following to the bashrc, save and exit.
3. Open a new terminal window and browse your git repo :)parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[01;31m\]$(parse_git_branch)\[\033[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w$(parse_git_branch)\$ '
fi
unset color_prompt force_color_prompt
Hi,
ReplyDeleteThank you for the information , I also recently google looking for a similar code, to show up which branch i'm currently working on when i'm in a git repository.
and I found these 2 repos liquidprompt[1] and git-aware-prompt[2]
git-aware-prompt dose a similar thing what you have mentioned here
liquidprompt is a greate tool to make your bash in to smart terminal
[1] : https://github.com/nojhan/liquidprompt
[2] : https://github.com/jimeh/git-aware-prompt
again Thanks for sharing this code :)