-
Notifications
You must be signed in to change notification settings - Fork 3
Description
Hello
Presently the prompt string generated lack option of adding a Current Git Branch in the prompt string for display in the Bash prompt.
After some fiddling, I was able to get it working. We just need to add the char sequence for displaying current Git Branch in the prompt string in .bashrc file.
For example(Fiery Orange) :
#GIT_BRANCH='[\033[38;5;12m]$(git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* (.*)/(\1)/')'
export PS1="[\e[38;5;196m]\u[\e[38;5;202m]@[\e[38;5;208m]\h [\e[38;5;220m]\w ${GIT_BRANCH} [\033[0m]$ "
Also to remove the redundant space before $ and cwd in prompt add this before
So, finally my PS1 in .bashrc looks like:
export PS1="[\e[38;5;196m]\u[\e[38;5;202m]@[\e[38;5;208m]\h [\e[38;5;220m]\w [$(tput sgr0)]>[\033[38;5;12m]${GIT_BRANCH}[\033[0m]$ "
Hope it helps!