You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

16 lines
485 B

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