From 2b6e24131d7af12706e2ca15fe574cc19bcc82fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacek=20Sowi=C5=84ski?= Date: Wed, 9 Dec 2009 00:14:31 +0100 Subject: [PATCH] add bash completion for ncmpcpp --- doc/ncmpcpp-completion.bash | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 doc/ncmpcpp-completion.bash diff --git a/doc/ncmpcpp-completion.bash b/doc/ncmpcpp-completion.bash new file mode 100644 index 00000000..49222c4b --- /dev/null +++ b/doc/ncmpcpp-completion.bash @@ -0,0 +1,34 @@ +# Installation: +# - If you have system bash completion, place this in /etc/bash_completion.d or +# source it from $HOME/.bash_completion +# - If you don't have system bash completion, source this from your .bashrc + + _ncmpcpp () +{ + local cur prev cmds opts + + cur="$2" + prev="$3" + cmds=`ncmpcpp --help 2>&1 | awk '/^ [a-z]+ /{print $1}'`; + opts="`ncmpcpp --help 2>&1 | awk '/^ -.+,/{print $1 "\n" $2}' | sed -e 's/,//;$a--now-playing'`" + + case "$prev" in + ncmpcpp) + COMPREPLY=($(compgen -W '$opts $cmds' -- "$cur")) + ;; + --port|-p|--host|-h) + COMPREPLY=() + ;; + --help|-?|--version|-v|--now-playing) + return + ;; + next|pause|play|prev|stop|toggle|volume) + opts="`echo $opts | sed -e 's/--port//;s/--host//;s/-p//;s/-h//'`" + COMPREPLY=($(compgen -W '$opts' -- "$cur")) + ;; + *) + COMPREPLY=($(compgen -W '$opts $cmds' -- "$cur")) + ;; + esac +} +complete -F _ncmpcpp ncmpcpp