bash-completion: localectl: add a missing option and verbs

This commit is contained in:
Yu Watanabe 2018-01-10 17:02:38 +09:00
parent 29e08b9e9e
commit f822279e62

View file

@ -35,7 +35,7 @@ _localectl() {
local i verb comps locale_vals
local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
local OPTS='-h --help --version --no-convert --no-pager --no-ask-password
-H --host --machine'
-H --host -M --machine'
if __contains_word "$prev" $OPTS; then
case $prev in
@ -53,10 +53,11 @@ _localectl() {
fi
local -A VERBS=(
[STANDALONE]='status list-locales list-keymaps'
[LOCALES]='set-locale'
[KEYMAPS]='set-keymap'
[X11]='set-x11-keymap'
[STANDALONE]='status list-locales list-keymaps list-x11-keymap-models list-x11-keymap-layouts list-x11-keymap-options'
[VARIANTS]='list-x11-keymap-variants'
[LOCALES]='set-locale'
[KEYMAPS]='set-keymap'
[X11]='set-x11-keymap'
)
for ((i=0; i < COMP_CWORD; i++)); do
@ -68,6 +69,8 @@ _localectl() {
if [[ -z $verb ]]; then
comps=${VERBS[*]}
elif __contains_word "$verb" ${VERBS[VARIANTS]}; then
comps=$(command localectl list-x11-keymap-layouts)
elif __contains_word "$verb" ${VERBS[LOCALES]}; then
if [[ $cur = *=* ]]; then
mapfile -t locale_vals < <(command localectl list-locales 2>/dev/null)