From: Yann E. MORIN Date: Tue, 1 Jul 2014 18:14:25 +0000 (+0200) Subject: pwclient: add bash completion for project names X-Git-Tag: v0.9.0~47 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fb4a5f3f957c756c4a9a42b5cd84fc425e10c827;p=thirdparty%2Fpatchwork.git pwclient: add bash completion for project names Add initial bash-completion, which so far only completes on the project names. Signed-off-by: "Yann E. MORIN" Signed-off-by: Jeremy Kerr --- diff --git a/apps/patchwork/bin/bash_completion b/apps/patchwork/bin/bash_completion new file mode 100644 index 00000000..a120a76f --- /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