diff --git a/Examples-(completion).md b/Examples-(completion).md index f3cc0ad..379e1fb 100644 --- a/Examples-(completion).md +++ b/Examples-(completion).md @@ -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}' +} ``` \ No newline at end of file