Last active
September 3, 2017 09:02
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_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