From 7970d36fa98aef4723a6a43e7d47c1a34cddf31b Mon Sep 17 00:00:00 2001 From: Noah Masur Date: Wed, 25 Nov 2020 23:03:52 -0500 Subject: [PATCH] git add fuzzy --- fish.configlink/functions/gittools.fish | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/fish.configlink/functions/gittools.fish b/fish.configlink/functions/gittools.fish index 54295e4..93d104c 100644 --- a/fish.configlink/functions/gittools.fish +++ b/fish.configlink/functions/gittools.fish @@ -36,6 +36,22 @@ function gittools and git show $commit end + function git-add-fuzzy + set gitfile (git status -s \ + | fzf \ + --height 50% \ + -m \ + --preview-window right:70% \ + --preview 'set -l IFS; set gd (git diff --color=always (echo {} | awk \'{$1=$1};1\' | cut -d" " -f2)); if test "$gd"; echo "$gd"; else; bat (echo {} | awk \'{$1=$1};1\' | cut -d" " -f2); end') + and for gf in $gitfile + set gf (echo $gf \ + | awk '{$1=$1};1' \ + | cut -d' ' -f2 \ + ) + and git add $gf + end + end + function git-merge-fuzzy set branch (git-fuzzy-branch "merge from...") and git merge $branch @@ -56,6 +72,8 @@ function gittools switch $argv[1] case "checkout" git-checkout-fuzzy + case "add" + git-add-fuzzy case "show" git-show-fuzzy case "merge"