Compare commits

...

2 Commits

Author SHA1 Message Date
bretello 72a02e22e0
zsh: git: do not fail when aliases are undefined 2022-08-18 16:37:24 +02:00
karajan1001 b2df319e18 Add four new git function with the help of fzf 2022-08-18 20:56:34 +08:00
1 changed files with 47 additions and 0 deletions

View File

@ -74,3 +74,50 @@ compdef "__git_completion_wrapper __git_branch_names" git-diff-branch
function git-show-changes(){
git log --reverse HEAD^..
}
# oh-my-zsh has some aliases which we might want to override
# with functions
function _disable_alias() {
[[ -n $(alias "$1") ]] && unalias "$1"
}
_disable_alias gco
function gco() {
if [[ "$#" -ge 1 ]]; then
g checkout $@
elif [[ "$#" -eq 0 ]]; then
g checkout $(gb | fzf)
fi
}
_disable_alias gcor
function gcor() {
if [[ "$#" -ge 1 ]]; then
g checkout $@
elif [[ "$#" -eq 0 ]]; then
g checkout --track $(gbr | fzf)
fi
}
_disable_alias gbd
function gbd() {
if [[ "$#" -ge 1 ]]; then
g branch -d $@
elif [[ "$#" -eq 0 ]]; then
g branch -d $(gb | fzf -m)
fi
}
_disable_alias gbD
function gbD() {
if [[ "$#" -ge 1 ]]; then
g branch -D $@
elif [[ "$#" -eq 0 ]]; then
g branch -D $(gb | fzf -m)
fi
}