aliases for fuzzy git, replacing normal command

This commit is contained in:
Noah Masur 2020-11-25 09:59:43 -05:00
parent 8c4e802f7d
commit fa1a40112d
2 changed files with 36 additions and 4 deletions

View File

@ -30,9 +30,9 @@ function aliases --description 'All aliases'
abbr -a gco 'git checkout'
abbr -a gcom 'git checkout master'
abbr -a gcob 'git checkout -b'
abbr -a gcof 'git-checkout-fuzzy'
abbr -a gb 'git branch'
abbr -a gbd 'git-delete-fuzzy'
abbr -a gbd 'git branch -d'
abbr -a gbD 'git branch -D'
abbr -a gr 'git reset'
abbr -a grh 'git reset --hard'
abbr -a gm 'git merge'

View File

@ -14,11 +14,43 @@ function gittools
end
function git-merge-fuzzy
git merge (git-fuzzy-branch "merge from...")
set branch (git-fuzzy-branch "merge from...")
and git merge
end
function git-delete-fuzzy
git branch -d (git-fuzzy-branch "delete branch...")
set branch (git-fuzzy-branch "delete branch...")
and git branch -d
end
function git-force-delete-fuzzy
set branch (git-fuzzy-branch "force delete branch...")
and git branch -D
end
function git
if contains f $argv
switch $argv[1]
case "checkout"
git-checkout-fuzzy
case "merge"
git-merge-fuzzy
case "branch"
if test "$argv[2]" = "-d"
git-delete-fuzzy
else if test "$argv[2]" = "-D"
git-force-delete-fuzzy
else
echo "Not a fuzzy option."
return 1
end
case "*"
echo "No fuzzy option."
return 1
end
else
command git $argv
end
end
end