chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
bash-completion: --property support
[elogind.git]
/
shell-completion
/
bash
/
systemctl
diff --git
a/shell-completion/bash/systemctl
b/shell-completion/bash/systemctl
index f24a1454245b8afb2032f1e0fa582ed5796417f8..3bdf4dc956bdf790418a8cd7653929b652c9fc2b 100644
(file)
--- a/
shell-completion/bash/systemctl
+++ b/
shell-completion/bash/systemctl
@@
-22,6
+22,15
@@
__systemctl() {
systemctl $mode --full --no-legend "$@"
}
systemctl $mode --full --no-legend "$@"
}
+__systemd_properties() {
+ local mode=$1
+ { __systemctl $mode show;
+ systemd --dump-configuration-items; } |
+ while IFS='=' read -r key value; do
+ [[ $value ]] && echo "$key"
+ done
+}
+
__contains_word () {
local word=$1; shift
for w in $*; do [[ $w = $word ]] && return 0; done
__contains_word () {
local word=$1; shift
for w in $*; do [[ $w = $word ]] && return 0; done
@@
-67,6
+76,12
@@
_systemctl () {
[ARG]='--host -H --kill-mode --kill-who --property -p --signal -s --type -t --root'
)
[ARG]='--host -H --kill-mode --kill-who --property -p --signal -s --type -t --root'
)
+ if __contains_word "--user" ${COMP_WORDS[*]}; then
+ mode=--user
+ else
+ mode=--system
+ fi
+
if __contains_word "$prev" ${OPTS[ARG]}; then
case $prev in
--signal|-s)
if __contains_word "$prev" ${OPTS[ARG]}; then
case $prev in
--signal|-s)
@@
-89,7
+104,7
@@
_systemctl () {
comps=$(compgen -A hostname)
;;
--property|-p)
comps=$(compgen -A hostname)
;;
--property|-p)
- comps=
''
+ comps=
$(__systemd_properties $mode)
;;
esac
COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
;;
esac
COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
@@
-101,12
+116,6
@@
_systemctl () {
return 0
fi
return 0
fi
- if __contains_word "--user" ${COMP_WORDS[*]}; then
- mode=--user
- else
- mode=--system
- fi
-
local -A VERBS=(
[ALL_UNITS]='is-active is-failed is-enabled status show mask preset'
[ENABLED_UNITS]='disable'
local -A VERBS=(
[ALL_UNITS]='is-active is-failed is-enabled status show mask preset'
[ENABLED_UNITS]='disable'