From: "Yann E. MORIN" <[email protected]> Add initial bash-completion, which so far only completes on the project names.
Signed-off-by: "Yann E. MORIN" <[email protected]> --- It should work with any version of bash-completion, although I have only tested it with bash-completion 2.0. The main change in bash-completion 2.0 is the addition of _init_completion that is responsible for initialising the variables, which must be done manualy otherwise. --- apps/patchwork/bin/bash_completion | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 apps/patchwork/bin/bash_completion diff --git a/apps/patchwork/bin/bash_completion b/apps/patchwork/bin/bash_completion new file mode 100644 index 0000000..a120a76 --- /dev/null +++ b/apps/patchwork/bin/bash_completion @@ -0,0 +1,29 @@ +# Autocompletion for bash. + +_pwclient() { + local cur prev words cword split + + if declare -f _init_completion >/dev/null; then + _init_completion -s || return + else + cur=$(_get_cword) + prev=${COMP_WORDS[COMP_CWORD-1]} + fi + + case "${COMP_CWORD}" in + 0|1) return 0;; + esac + + projects="$(sed -r -e '/\[options\]/d;' \ + -e '/^\[(.+)\]$/!d;' \ + -e 's//\1/;' ~/.pwclientrc 2>/dev/null)" + + case "${prev}" in + -p) COMPREPLY=( $(compgen -W "${projects}" -- "${cur}" ) );; + esac + + return 0 +} +complete -F _pwclient pwclient + +# vim: ft=sh -- 1.8.3.2 _______________________________________________ Patchwork mailing list [email protected] https://lists.ozlabs.org/listinfo/patchwork
