From: Francois Fleuret Date: Mon, 3 May 2021 08:56:31 +0000 (+0200) Subject: Added the git branch info to PS1. X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=commitdiff_plain;h=750f872cb118f152b3cf7c1756486667e472aa18;p=scripts.git Added the git branch info to PS1. --- diff --git a/bashrc b/bashrc index f50d7cc..f312fc0 100644 --- a/bashrc +++ b/bashrc @@ -908,6 +908,20 @@ function mvtoconfig () { fi } + +###################################################################### +# git prompt + +if which > /dev/null git +then + + parse_git_branch() { + git 2>/dev/null rev-parse --abbrev-ref HEAD | sed -e 's/^\(.*\)$/(\1) /' + } + + export PS_GIT="${VT_WHITE_BG}${VT_GREEN_FG}\$(parse_git_branch)${VT_RESET}" +fi + ###################################################################### # The complex prompt policy @@ -955,7 +969,7 @@ else fi -PS1="${PSCUE}${PS1}" +PS1="${PS_GIT}${PSCUE}${PS1}" ###################################################################### # This implements a local history. If we are in a directory containing