m/fzf
1
0
mirror of https://github.com/junegunn/fzf.git synced 2025-11-17 15:53:39 -05:00

Added git expansion for checkout based on hg expansion

Ruben Berenguel
2017-08-29 21:36:23 +01:00
parent e66414033c
commit 9e6c436d54

@@ -86,4 +86,27 @@ _fzf_complete_hg() {
_fzf_complete_hg_post() {
cut -f1 -d' '
}
```
### Complete `git co` (for example)
You can use the same approach as above to complete any git command. In the example below, completion is triggered on `git co` (usual alias for `git checkout`):
```sh
_fzf_complete_git() {
ARGS="$@"
local branches
branches=$(git branch -vv --all)
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}'
}
```