summaryrefslogtreecommitdiff
path: root/shell-completion
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2014-02-06 11:59:33 -0500
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2014-02-06 12:01:39 -0500
commit627a98d39844a1ac10fde1f72cf18b4f08be4990 (patch)
tree5368d72462a7bfa239577753243b87f2fa049807 /shell-completion
parent5d63309cf5a6fc5256391fa4ddb72cf68e2e27e5 (diff)
downloadsystemd-627a98d39844a1ac10fde1f72cf18b4f08be4990.tar.gz
shell-completion: fix completion of localectl set-locale
https://bugs.freedesktop.org/show_bug.cgi?id=74157
Diffstat (limited to 'shell-completion')
-rw-r--r--shell-completion/bash/localectl20
-rw-r--r--shell-completion/zsh/_localectl13
2 files changed, 27 insertions, 6 deletions
diff --git a/shell-completion/bash/localectl b/shell-completion/bash/localectl
index 84e2a6b09e..c9e22af2aa 100644
--- a/shell-completion/bash/localectl
+++ b/shell-completion/bash/localectl
@@ -24,8 +24,14 @@ __contains_word () {
done
}
+__locale_fields=( LANG LANGUAGE LC_CTYPE LC_NUMERIC LC_TIME \
+ LC_COLLATE LC_MONETARY LC_MESSAGES LC_PAPER \
+ LC_NAME LC_ADDRESS LC_TELEPHONE \
+ LC_MEASUREMENT LC_IDENTIFICATION )
+# LC_ALL is omitted on purpose
+
_localectl() {
- local i verb comps
+ 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'
@@ -62,7 +68,17 @@ _localectl() {
if [[ -z $verb ]]; then
comps=${VERBS[*]}
elif __contains_word "$verb" ${VERBS[LOCALES]}; then
- comps=$(command localectl list-locales)
+ if [[ $cur = *=* ]]; then
+ mapfile -t locale_vals < <(command localectl list-locales 2>/dev/null)
+ COMPREPLY=( $(compgen -W '${locale_vals[*]}' -- "${cur#=}") )
+ elif [[ $prev = "=" ]]; then
+ mapfile -t locale_vals < <(command localectl list-locales 2>/dev/null)
+ COMPREPLY=( $(compgen -W '${locale_vals[*]}' -- "$cur") )
+ else
+ compopt -o nospace
+ COMPREPLY=( $(compgen -W '${__locale_fields[*]}' -S= -- "$cur") )
+ fi
+ return 0
elif __contains_word "$verb" ${VERBS[KEYMAPS]}; then
comps=$(command localectl list-keymaps)
elif __contains_word "$verb" ${VERBS[STANDALONE]} ${VERBS[X11]}; then
diff --git a/shell-completion/zsh/_localectl b/shell-completion/zsh/_localectl
index 3d76bb0c4d..c04f4f3109 100644
--- a/shell-completion/zsh/_localectl
+++ b/shell-completion/zsh/_localectl
@@ -1,17 +1,22 @@
#compdef localectl
_localectl_set-locale() {
- local -a _confs _locales
+ local -a _locales locale_fields
+ locale_fields=(LANG LANGUAGE LC_CTYPE LC_NUMERIC LC_TIME \
+ LC_COLLATE LC_MONETARY LC_MESSAGES LC_PAPER \
+ LC_NAME LC_ADDRESS LC_TELEPHONE \
+ LC_MEASUREMENT LC_IDENTIFICATION)
+ # LC_ALL is omitted on purpose
+
local expl suf
_locales=( ${(f)"$(_call_program locales "$service" list-locales)"} )
- _confs=( ${${(f)"$(_call_program confs "locale 2>/dev/null")"}%\=*} )
+ compset -P1 '*='
if [[ -prefix 1 *\= ]]; then
local conf=${PREFIX%%\=*}
- compset -P1 '*='
_wanted locales expl "locales configs" \
_combination localeconfs confs=$conf locales "$@" -
else
- compadd -S '=' $_confs
+ compadd -S '=' $locale_fields
fi
}