From 37cde4ed5d2e9130703cb6e08cf47b9e9bceb9b1 Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Wed, 8 May 2013 11:09:15 +0200 Subject: share/bash-completion: add simple bash-completion --- contrib/bash-completion | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 contrib/bash-completion diff --git a/contrib/bash-completion b/contrib/bash-completion new file mode 100644 index 0000000..7f68819 --- /dev/null +++ b/contrib/bash-completion @@ -0,0 +1,20 @@ +# hostinfo completion + +_hostinfo_hosts="$(for file in /usr/local/share/hostinfo/* ; do basename $file | sed 's/.spline.inf.fu-berlin.de//' ; done)" + +_hostinfo() { + local cur prev + + COMPREPLY=() + _get_comp_words_by_ref cur prev + + _get_first_arg + if [[ -z "$arg" ]]; then + _completion="$_hostinfo_hosts" + else + _completion="hostname os arch addresses ports vserver vserver-host" + fi + + COMPREPLY=( $( compgen -W "-o --oneline $_completion" -- $cur ) ) +} +complete -F _hostinfo hostinfo -- cgit v1.2.3-1-g7c22