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"
|
function snag -d "Pick desired files from a chosen branch"
|
||||||
# use fzf to choose source branch to snag files FROM
|
# 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)
|
||||||
# use fzf to choose files that differ from current branch
|
# avoid doing work if branch isn't set
|
||||||
set files (git diff --name-only $branch | fzf --height 10% --layout=reverse --border --multi)
|
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
|
# avoid checking out branch if files aren't specified
|
||||||
if set -q files
|
if test -n "$files"
|
||||||
git checkout $branch $files
|
git checkout $branch $files
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user