Skip to content

Commit fb9d85b

Browse files
committed
zsh-completion: _loginctl/_systemd/_systemd-inhibit improvements
_loginctl: respects the verbose style. which allows a user to get the pre d5df0d9 behavior of not showing a description for sessions and users, by default they aren't shown. zstyle ':completion:*' verbose true or zstyle ':completion:*:loginctl*:*' verbose true # or similar Will show the descriptions. zstyle ':completion:*' verbose true and zstyle ':completion:*:loginctl*:*' verbose false # or similar Won't show descriptions for loginctl only _systemd: complete pids for systemd-notify's --pid option. display a message of the expected argument for other options. _systemd-inhibit: complete block & delay for --mode display a message of the expected argument for --who/--why
1 parent 38cf1e2 commit fb9d85b

File tree

3 files changed

+30
-14
lines changed

3 files changed

+30
-14
lines changed

shell-completion/zsh/_loginctl

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,12 @@ for fun in session-status show-session activate lock-session unlock-session term
3737
_sys_all_sessions_descr[(i)$_ignore:*]=()
3838
done
3939

40-
_describe -t systemd-sessions session _sys_all_sessions_descr _sys_all_sessions "$@"
40+
if zstyle -T ":completion:${curcontext}:systemd-sessions" verbose; then
41+
_describe -t systemd-sessions session _sys_all_sessions_descr _sys_all_sessions "$@"
42+
else
43+
local expl
44+
_wanted systemd-sessions expl session compadd "$@" -a _sys_all_sessions
45+
fi
4146
}
4247
done
4348

@@ -56,8 +61,14 @@ for fun in user-status show-user enable-linger disable-linger terminate-user kil
5661
_sys_all_users[(i)$_ignore]=()
5762
_sys_all_users_descr[(i)$_ignore:*]=()
5863
done
64+
5965
# using the common tag `users' here, not rolling our own `systemd-users' tag
60-
_describe -t users user ${_sys_all_users_descr:+_sys_all_users_descr} _sys_all_users "$@"
66+
if zstyle -T ":completion:${curcontext}:users" verbose; then
67+
_describe -t users user ${_sys_all_users_descr:+_sys_all_users_descr} _sys_all_users "$@"
68+
else
69+
local expl
70+
_wanted users expl user compadd "$@" -a _sys_all_users
71+
fi
6172
}
6273
done
6374

@@ -72,7 +83,12 @@ done
7283
_sys_all_seats_descr[(i)$_ignore:*]=()
7384
done
7485

75-
_describe -t systemd-seats seat _sys_all_seats_descr _sys_all_seats "$@"
86+
if zstyle -T ":completion:${curcontext}:systemd-seats" verbose; then
87+
_describe -t systemd-seats seat _sys_all_seats_descr _sys_all_seats "$@"
88+
else
89+
local expl
90+
_wanted systemd-seats expl seat compadd "$@" -a _sys_all_seats
91+
fi
7692
}
7793
for fun in seat-status show-seat terminate-seat ; do
7894
(( $+functions[_loginctl_$fun] )) || _loginctl_$fun()

shell-completion/zsh/_systemd

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ case "$service" in
55
systemd-ask-password)
66
_arguments \
77
{-h,--help}'[Show this help]' \
8-
'--icon=[Icon name]' \
9-
'--timeout=[Timeout in sec]' \
8+
'--icon=[Icon name]:icon name:' \
9+
'--timeout=[Timeout in sec]:timeout (seconds):' \
1010
'--no-tty[Ask question via agent even on TTY]' \
1111
'--accept-cached[Accept cached passwords]' \
1212
'--multiple[List multiple passwords if available]'
@@ -15,7 +15,7 @@ case "$service" in
1515
_arguments \
1616
{-h,--help}'[Show this help]' \
1717
'--version[Show package version.]' \
18-
{-t+,--identifier=}'[Set syslog identifier.]' \
18+
{-t+,--identifier=}'[Set syslog identifier.]:syslog identifier:' \
1919
{-p+,--priority=}'[Set priority value.]:value:({0..7})' \
2020
'--level-prefix=[Control whether level prefix shall be parsed.]:boolean:(1 0)' \
2121
':Message'
@@ -38,10 +38,10 @@ case "$service" in
3838
'(-m -p -i -t)-c[Order by CPU load]' \
3939
'(-c -p -i -t)-m[Order by memory load]' \
4040
'(-c -m -p -t)-i[Order by IO load]' \
41-
{-d+,--delay=}'[Specify delay]' \
42-
{-n+,--iterations=}'[Run for N iterations before exiting]' \
41+
{-d+,--delay=}'[Specify delay]:delay:' \
42+
{-n+,--iterations=}'[Run for N iterations before exiting]:number of iterations:' \
4343
{-b,--batch}'[Run in batch mode, accepting no input]' \
44-
'--depth=[Maximum traversal depth]'
44+
'--depth=[Maximum traversal depth]:maximum depth:'
4545
;;
4646
systemd-detect-virt)
4747
_arguments \
@@ -61,8 +61,8 @@ case "$service" in
6161
{-h,--help}'[Show this help]' \
6262
'--version[Show package version]' \
6363
'--ready[Inform the init system about service start-up completion.]' \
64-
'--pid=[Inform the init system about the main PID of the daemon]' \
65-
'--status=[Send a free-form status string for the daemon to the init systemd]' \
64+
'--pid=[Inform the init system about the main PID of the daemon]:daemon main PID:_pids' \
65+
'--status=[Send a free-form status string for the daemon to the init systemd]:status string:' \
6666
'--booted[Returns 0 if the system was booted up with systemd]'
6767
;;
6868
systemd-tty-ask-password-agent)

shell-completion/zsh/_systemd-inhibit

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ _arguments \
2626
{-h,--help}'[Show this help]' \
2727
'--version[Show package version]' \
2828
'--what=[Operations to inhibit]:options:_inhibit_what' \
29-
'--who=[A descriptive string who is inhibiting]' \
30-
'--why=[A descriptive string why is being inhibited]' \
31-
'--mode=[One of block or delay]' \
29+
'--who=[A descriptive string who is inhibiting]:who is inhibiting:' \
30+
'--why=[A descriptive string why is being inhibited]:reason for the lock:' \
31+
'--mode=[One of block or delay]:lock mode:( block delay )' \
3232
'--list[List active inhibitors]' \
3333
'*:commands:_systemd_inhibit_command'

0 commit comments

Comments
 (0)