dotfiles/dot_config/fish/conf.d/30-git.fish
punkfairie 91ce6c48d6
Update .config/fish/conf.d/10-starship.fish
Update .config/fish/conf.d/20-gpg.fish
Update .config/fish/conf.d/30-chezmoi.fish
Update .config/fish/conf.d/30-eza.fish
Update .config/fish/conf.d/30-fzf.fish
Update .config/fish/conf.d/30-git.fish
Update .config/fish/conf.d/30-go.fish
Update .config/fish/conf.d/30-journalctl.fish
Update .config/fish/conf.d/30-lazygit.fish
Update .config/fish/conf.d/30-less.fish
Update .config/fish/conf.d/30-php.fish
Remove .config/fish/conf.d/30-polybar.fish
Update .config/fish/conf.d/30-systemctl.fish
Update .config/fish/conf.d/30-volta.fish
Update .config/fish/conf.d/30-wget.fish
Update .config/fish/conf.d/30-yay.fish
Update .config/fish/conf.d/30-bitwarden.fish
Update .config/topgrade.d/01-commands.toml
2024-10-02 21:01:45 -07:00

52 lines
1.4 KiB
Fish

#!/usr/bin/env fish
if command -v git &>/dev/null
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
end