diff --git a/.config/bash/module/git.sh b/.config/bash/module/git.sh index e4294cc..4f9c615 100644 --- a/.config/bash/module/git.sh +++ b/.config/bash/module/git.sh @@ -74,6 +74,12 @@ gg() git clone https://git.voronind.com/voronind/"${1}" } +# Show current branch. +_git_current_branch() +{ + git branch --show-current 2> /dev/null +} + # autocomplete. _completion_loader git &> /dev/null __git_complete gps _git_push &> /dev/null diff --git a/.config/bash/module/ps1.sh b/.config/bash/module/ps1.sh index 52e1098..c177733 100644 --- a/.config/bash/module/ps1.sh +++ b/.config/bash/module/ps1.sh @@ -40,8 +40,12 @@ __prompt_command() # add user, host and working dir PS1+="\u@\h " PS1+="\[${color_blue}\]" - PS1+="\w" - # PS1+="\${PWD}" + # PS1+="\w" + PS1+="\${PWD}" + + # Add git branch if available. + local git_branch="$(_git_current_branch)" + [[ "${git_branch}" = "" ]] || PS1+=" ${color_blue}@${git_branch}" # set error red if $is_error; then