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

View File

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