PS1 : add git branch.

This commit is contained in:
Dmitry Voronin 2023-11-27 21:18:55 +03:00
parent 9cda3d222a
commit 125ef0af69
2 changed files with 12 additions and 2 deletions

View file

@ -74,6 +74,12 @@ gg()
git clone https://git.voronind.com/voronind/"${1}" git clone https://git.voronind.com/voronind/"${1}"
} }
# Show current branch.
_git_current_branch()
{
git branch --show-current 2> /dev/null
}
# autocomplete. # autocomplete.
_completion_loader git &> /dev/null _completion_loader git &> /dev/null
__git_complete gps _git_push &> /dev/null __git_complete gps _git_push &> /dev/null

View file

@ -40,8 +40,12 @@ __prompt_command()
# add user, host and working dir # add user, host and working dir
PS1+="\u@\h " PS1+="\u@\h "
PS1+="\[${color_blue}\]" PS1+="\[${color_blue}\]"
PS1+="\w" # PS1+="\w"
# PS1+="\${PWD}" PS1+="\${PWD}"
# Add git branch if available.
local git_branch="$(_git_current_branch)"
[[ "${git_branch}" = "" ]] || PS1+=" ${color_blue}@${git_branch}"
# set error red # set error red
if $is_error; then if $is_error; then