mirror of
https://github.com/junegunn/fzf.git
synced 2025-11-18 16:45:38 -05:00
updated my snag method to be lazier if either input isn't specified
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user