Skip to content

Instantly share code, notes, and snippets.

@rberenguel
Last active September 3, 2017 09:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rberenguel/51f8b157eefa7bf5fe95c19cb6eef9a2 to your computer and use it in GitHub Desktop.
Save rberenguel/51f8b157eefa7bf5fe95c19cb6eef9a2 to your computer and use it in GitHub Desktop.
Fzf (see https://github.com/junegunn/fzf) completion for git checkout (which I have aliased to co). See (a previous version without origin removal) in action here: https://asciinema.org/a/DCZH8q4mZHr79uVGZcM5RCtRb
_fzf_complete_git() {
ARGS="$@"
local branches
branches=$(git branch -vv --all | sed "s/remotes\/origin\///g" | sed "s/\*/ /g")
if [[ $ARGS == 'git co'* ]]; then
_fzf_complete "--reverse --multi" "$@" < <(
echo $branches
)
else
eval "zle ${fzf_default_completion:-expand-or-complete}"
fi
}
_fzf_complete_git_post() {
awk '{print $1}'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment