summaryrefslogtreecommitdiff
path: root/bash-completion/systemd-bash-completion.sh
diff options
context:
space:
mode:
authorDave Reisner <dreisner@archlinux.org>2012-10-20 17:48:11 -0400
committerDave Reisner <dreisner@archlinux.org>2012-10-20 17:48:11 -0400
commit26be51de330e544ade97a9345bbfa60d5674cb7a (patch)
tree345ca314ba2f19161002bc0cc5213c527707644a /bash-completion/systemd-bash-completion.sh
parent0962e09ec305124d2a8dcb0269cf11c4bcdef715 (diff)
bash-completion: add completions for hostnamectl
Diffstat (limited to 'bash-completion/systemd-bash-completion.sh')
-rw-r--r--bash-completion/systemd-bash-completion.sh35
1 files changed, 35 insertions, 0 deletions
diff --git a/bash-completion/systemd-bash-completion.sh b/bash-completion/systemd-bash-completion.sh
index 636c800310..1a7df57649 100644
--- a/bash-completion/systemd-bash-completion.sh
+++ b/bash-completion/systemd-bash-completion.sh
@@ -439,3 +439,38 @@ _localectl() {
return 0
}
complete -F _localectl localectl
+
+_hostnamectl() {
+ local verb comps
+ local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
+ local OPTS='-h --help --version --transient --static --pretty
+ --no-ask-password -H --host'
+
+ if [[ $cur = -* ]]; then
+ COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") )
+ return 0
+ fi
+
+ local -A VERBS=(
+ [STANDALONE]='status'
+ [ICONS]='set-icon-name'
+ [NAME]='set-hostname'
+ )
+
+ for ((i=0; i <= COMP_CWORD; i++)); do
+ if __contains_word "${COMP_WORDS[i]}" ${VERBS[*]}; then
+ verb=${COMP_WORDS[i]}
+ break
+ fi
+ done
+
+ if [[ -z $verb ]]; then
+ comps=${VERBS[*]}
+ elif __contains_word "$verb" ${VERBS[STANDALONE]} ${VERBS[ICONS]} ${VERBS[NAME]}; then
+ comps=''
+ fi
+
+ COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
+ return 0
+}
+complete -F _hostnamectl hostnamectl