mirror of
https://github.com/junegunn/fzf.git
synced 2025-11-18 08:13:40 -05:00
Added git expansion for checkout based on hg expansion
@@ -86,4 +86,27 @@ _fzf_complete_hg() {
|
|||||||
_fzf_complete_hg_post() {
|
_fzf_complete_hg_post() {
|
||||||
cut -f1 -d' '
|
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}'
|
||||||
|
}
|
||||||
```
|
```
|
||||||
Reference in New Issue
Block a user