git: add support for tags, fix remote support, show commit hash next to checkout name

This commit is contained in:
Nicole O'Connor 2023-08-08 13:59:59 -07:00
parent 03c525d890
commit 35f517070b
1 changed files with 4 additions and 2 deletions

View File

@ -17,7 +17,9 @@ function git_prompt() {
if [[ "${branchtype}" == "refs" ]]; then
branchname=$(echo ${fullbranchname} | cut -d"/" -f3)
elif [[ "${branchtype}" == "remotes" ]]; then
branchname=$(echo ${commithash} | cut -d"/" -f2-)
branchname=$(echo ${fullbranchname} | cut -d"/" -f2-)
elif [[ "${branchtype}" == "tags" ]]; then
branchname=$(echo ${fullbranchname} | cut -d"/" -f2)
elif [[ "${branchtype}" == "${fullbranchname}" ]]; then
# git did it for us
branchname=${fullbranchname}
@ -27,7 +29,7 @@ function git_prompt() {
echo "warning: unrecognized branch type ${branchtype}" >&2
fi
print "%{$fg[yellow]%}${branchname}"
print "%{$fg_bold[yellow]%}${branchname} %{$fg[yellow]%}${commithash}"
fi
}