From 750f872cb118f152b3cf7c1756486667e472aa18 Mon Sep 17 00:00:00 2001 From: Francois Fleuret Date: Mon, 3 May 2021 10:56:31 +0200 Subject: [PATCH] Added the git branch info to PS1. --- bashrc | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) 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 -- 2.20.1