mirror of
https://github.com/junegunn/fzf.git
synced 2025-11-19 00:53:42 -05:00
Refined my fzf git checkout, allows passing in branch name to pre-fill search, and auto-checks out the branch if there's only 1 result
@@ -102,8 +102,9 @@ function fco -d "Fuzzy-find and checkout a branch"
|
|||||||
git branch --all | grep -v HEAD | string trim | fzf | read -l result; and git checkout "$result"
|
git branch --all | grep -v HEAD | string trim | fzf | read -l result; and git checkout "$result"
|
||||||
end
|
end
|
||||||
|
|
||||||
function fco -d "Fuzzy-find and checkout a branch (alternate method)"
|
function fco -d "Use `fzf` to choose which branch to check out" --argument-names branch
|
||||||
git for-each-ref --format='%(refname:short)' refs/heads | fzf --height 10% --layout=reverse --border | xargs git checkout
|
set -q branch[1]; or set branch ''
|
||||||
|
git for-each-ref --format='%(refname:short)' refs/heads | fzf --height 10% --layout=reverse --border --query=$branch --select-1 | xargs git checkout
|
||||||
end
|
end
|
||||||
|
|
||||||
function fcoc -d "Fuzzy-find and checkout a commit"
|
function fcoc -d "Fuzzy-find and checkout a commit"
|
||||||
|
|||||||
Reference in New Issue
Block a user