git fuzzy tools

This commit is contained in:
Noah Masur 2020-11-23 22:34:14 -05:00
parent 9910864059
commit e660ae797e
3 changed files with 28 additions and 0 deletions

View File

@ -38,6 +38,7 @@ if status --is-interactive
notes
awstools
mactools
gittools
projects
# Fuzzy finder

View File

@ -30,9 +30,12 @@ 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 grh 'git reset --hard'
abbr -a gm 'git merge'
abbr -a gmf 'git-merge-fuzzy'
abbr -a ghb 'gh repo view -w'
# Vim

View File

@ -0,0 +1,24 @@
#!/usr/local/bin/fish
function gittools
function git-fuzzy-branch -a header
set -l current (git rev-parse --abbrev-ref HEAD | tr -d '\n')
set -l branch (git branch --format "%(refname:short)" | eval "fzf $FZF_DEFAULT_OPTS --header='On $current, $header'")
and echo $branch
end
function git-checkout-fuzzy
set branch (git-fuzzy-branch "checkout branch...")
and git checkout $branch
end
function git-merge-fuzzy
git merge (git-fuzzy-branch "merge from...")
end
function git-delete-fuzzy
git branch -d (git-fuzzy-branch "delete branch...")
end
end