dotfiles/dot_config/fish/conf.d/30-git.fish
punkfairie 7dd8b445ca
Update .config/fish/conf.d/00-init.fish
Remove .config/fish/conf.d/10-apple-keyboard.fish
Update .config/fish/conf.d/20-gpg.fish
Update .config/fish/conf.d/30-git.fish
Change attributes of .config/fish/conf.d/30-glamour.fish
2024-09-29 20:57:09 -07:00

50 lines
1.3 KiB
Fish

#!/usr/bin/env fish
abbr -a g --position command git
################################################################################
# Functions #
################################################################################
function git_develop_branch
command git rev-parse --git-dir &>/dev/null || return
set -l branch
for branch in dev devel develop development
if command git show-ref -q --verify refs/heads/$branch
echo $branch
return 0
end
end
echo develop
return 1
end
function git_main_branch
command git rev-parse --git-dir &>/dev/null || return
set -l ref
for ref in
refs/{heads,remotes/{origin,upstream}}/{main,trunk,mainline,default,master}
if command git show-ref -q --verify $ref
echo (basename $ref)
return 0
end
end
echo main
return 1
end
function git_current_branch
set -l ref (git symbolic-ref --quiet HEAD 2>/dev/null)
set -l ret $status
if [ $ret -ne 0 ]
[ $ret -eq 128 ] && return # no git repo
set ref (git rev-parse --short HEAD 2>/dev/null) || return
end
echo (string replace "refs/heads/" "" $ref)
end