From 182b65aa130ce7fa8dcc21f34e06a5ad51016feb Mon Sep 17 00:00:00 2001 From: Yuri Bochkarev Date: Tue, 17 May 2016 19:04:20 +0400 Subject: [PATCH] Add example on how to implement branch name completion for hg update/hg merge --- Examples-(completion).md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Examples-(completion).md b/Examples-(completion).md index 908a18a..f3cc0ad 100644 --- a/Examples-(completion).md +++ b/Examples-(completion).md @@ -65,4 +65,25 @@ _fzf_complete_pass() { } [ -n "$BASH" ] && complete -F _fzf_complete_pass -o default -o bashdefault pass +``` + +### Complete hg update/hg merge + +If you need to add branch name completion for a subset of hg commands, e.g. hg up, hg merge, you can use technique as follows (zsh completion): + +```sh +_fzf_complete_hg() { + ARGS="$@" + if [[ $ARGS == 'hg merge'* ]] || [[ $ARGS == 'hg up'* ]]; then + _fzf_complete "--no-sort" "$@" < <( + { hg branches & hg tags } + ) + else + eval "zle ${fzf_default_completion:-expand-or-complete}" + fi +} + +_fzf_complete_hg_post() { + cut -f1 -d' ' +} ``` \ No newline at end of file