m/fzf
1
0
mirror of https://github.com/junegunn/fzf.git synced 2025-11-18 08:13:40 -05:00

updated my snag method to be lazier if either input isn't specified

Jesse Dupuy
2020-11-10 15:45:31 -08:00
parent 3c466e7c60
commit d89bcb5d73

@@ -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)
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 10% --layout=reverse --border --multi)
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