mirror of
https://github.com/lowne/fish-prompt-metro.git
synced 2024-10-27 20:34:12 +00:00
16 lines
485 B
Fish
16 lines
485 B
Fish
function git_branch_name -d "Get the name of the current Git branch, tag or sha1"
|
|
set -l branch_name (command git symbolic-ref --short HEAD 2>/dev/null)
|
|
|
|
if test -z "$branch_name"
|
|
set -l tag_name (command git describe --tags --exact-match HEAD 2>/dev/null)
|
|
|
|
if test -z "$tag_name"
|
|
command git rev-parse --short HEAD 2>/dev/null
|
|
else
|
|
printf "%s\n" "$tag_name"
|
|
end
|
|
else
|
|
printf "%s\n" "$branch_name"
|
|
end
|
|
end
|