From d89bcb5d7344e7a5e7cdcba5217094266103f803 Mon Sep 17 00:00:00 2001 From: Jesse Dupuy Date: Tue, 10 Nov 2020 15:45:31 -0800 Subject: [PATCH] updated my `snag` method to be lazier if either input isn't specified --- Examples-(fish).md | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Examples-(fish).md b/Examples-(fish).md index f58da31..8435e1c 100644 --- a/Examples-(fish).md +++ b/Examples-(fish).md @@ -113,11 +113,14 @@ end function snag -d "Pick desired files from a chosen branch" # use fzf to choose source branch to snag files FROM - set branch (git for-each-ref --format='%(refname:short)' refs/heads | fzf --height 10% --layout=reverse --border) - # use fzf to choose files that differ from current branch - set files (git diff --name-only $branch | fzf --height 10% --layout=reverse --border --multi) + set branch (git for-each-ref --format='%(refname:short)' refs/heads | fzf --height 20% --layout=reverse --border) + # avoid doing work if branch isn't set + if test -n "$branch" + # use fzf to choose files that differ from current branch + set files (git diff --name-only $branch | fzf --height 20% --layout=reverse --border --multi) + end # avoid checking out branch if files aren't specified - if set -q files + if test -n "$files" git checkout $branch $files end end