From b2df319e1844aed04e10d3e5d8b025b47bd75221 Mon Sep 17 00:00:00 2001 From: karajan1001 Date: Thu, 18 Aug 2022 20:56:34 +0800 Subject: [PATCH] Add four new git function with the help of fzf --- functions/git.zsh | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/functions/git.zsh b/functions/git.zsh index 697c4c7..f73e2a6 100644 --- a/functions/git.zsh +++ b/functions/git.zsh @@ -74,3 +74,43 @@ compdef "__git_completion_wrapper __git_branch_names" git-diff-branch function git-show-changes(){ git log --reverse HEAD^.. } + +unalias gco +function gco() { + if [[ "$#" -ge 1 ]]; then + g checkout $@ + elif [[ "$#" -eq 0 ]]; then + g checkout $(gb | fzf) + fi + +} + +unalias gcor +function gcor() { + if [[ "$#" -ge 1 ]]; then + g checkout $@ + elif [[ "$#" -eq 0 ]]; then + g checkout --track $(gbr | fzf) + fi + +} + +unalias gbd +function gbd() { + if [[ "$#" -ge 1 ]]; then + g branch -d $@ + elif [[ "$#" -eq 0 ]]; then + g branch -d $(gb | fzf -m) + fi +} + + +unalias gbD +function gbD() { + if [[ "$#" -ge 1 ]]; then + g branch -D $@ + elif [[ "$#" -eq 0 ]]; then + g branch -D $(gb | fzf -m) + fi +} +