Sometimes it’s handy to always see which branch of the repository we’re working in. We can display this as part of the terminal command prompt by adding a few things to our local .bashrc file.
~/.bashrc
12345678
function parse_git_branch { git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'}# This will display the current folder's full path.# If you want only the folder name, replace \w with \Wexport PS1="\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\u@\h:\w\[\033[36m\]\$(parse_git_branch)\[\033[0m\]\$ "
And now our command prompt looks like this:
1
you@host:~/Project/folder (master)$
The branch name will always be displayed in parenthesis for us.