mirror of
https://github.com/systemd/systemd-stable.git
synced 2024-12-22 13:33:56 +03:00
Merge pull request #248 from llua/zsh-completion
zsh-completion: _loginctl - general bug fixes
This commit is contained in:
commit
d5df0d950f
@ -1,15 +1,43 @@
|
||||
#compdef loginctl
|
||||
|
||||
_loginctl_all_sessions(){_sys_all_sessions=($(loginctl --no-legend list-sessions | { while read a b; do echo " $a"; done; }) )}
|
||||
_loginctl_all_users() {_sys_all_users=( $(loginctl --no-legend list-users | { while read a b; do echo " $a"; done; }) )}
|
||||
_loginctl_all_seats() {_sys_all_seats=( $(loginctl --no-legend list-seats | { while read a b; do echo " $a"; done; }) )}
|
||||
_loginctl_all_sessions() {
|
||||
local session description
|
||||
loginctl --no-legend list-sessions | while read -r session description; do
|
||||
_sys_all_sessions+=( "$session" )
|
||||
_sys_all_sessions_descr+=( "${session}:$description" )
|
||||
done
|
||||
}
|
||||
|
||||
_loginctl_all_users() {
|
||||
local uid description
|
||||
loginctl --no-legend list-users | while read -r uid description; do
|
||||
_sys_all_users+=( "$uid" )
|
||||
_sys_all_users_descr+=( "${uid}:$description" )
|
||||
done
|
||||
}
|
||||
|
||||
_loginctl_all_seats() {
|
||||
local seat description
|
||||
loginctl --no-legend list-seats | while read -r seat description; do
|
||||
_sys_all_seats+=( "$seat" )
|
||||
_sys_all_seats_descr+=( "${seat}:$description" )
|
||||
done
|
||||
}
|
||||
|
||||
local fun
|
||||
# Completion functions for SESSIONS
|
||||
for fun in session-status show-session activate lock-session unlock-session terminate-session kill-session ; do
|
||||
(( $+functions[_loginctl_$fun] )) || _loginctl_$fun()
|
||||
{
|
||||
local -a _sys_all_sessions{,_descr}
|
||||
|
||||
_loginctl_all_sessions
|
||||
compadd "$@" -a - _sys_all_sessions
|
||||
for _ignore in $words[2,-1]; do
|
||||
_sys_all_sessions[(i)$_ignore]=()
|
||||
_sys_all_sessions_descr[(i)$_ignore:*]=()
|
||||
done
|
||||
|
||||
_describe -t systemd-sessions session _sys_all_sessions_descr _sys_all_sessions "$@"
|
||||
}
|
||||
done
|
||||
|
||||
@ -17,16 +45,34 @@ done
|
||||
for fun in user-status show-user enable-linger disable-linger terminate-user kill-user ; do
|
||||
(( $+functions[_loginctl_$fun] )) || _loginctl_$fun()
|
||||
{
|
||||
_loginctl_all_users
|
||||
compadd "$@" -a - _sys_all_users
|
||||
local -a _sys_all_users{,_descr}
|
||||
zstyle -a ":completion:${curcontext}:users" users _sys_all_users
|
||||
|
||||
if ! (( $#_sys_all_users )); then
|
||||
_loginctl_all_users
|
||||
fi
|
||||
|
||||
for _ignore in $words[2,-1]; do
|
||||
_sys_all_users[(i)$_ignore]=()
|
||||
_sys_all_users_descr[(i)$_ignore:*]=()
|
||||
done
|
||||
# using the common tag `users' here, not rolling our own `systemd-users' tag
|
||||
_describe -t users user ${_sys_all_users_descr:+_sys_all_users_descr} _sys_all_users "$@"
|
||||
}
|
||||
done
|
||||
|
||||
# Completion functions for SEATS
|
||||
(( $+functions[_loginctl_seats] )) || _loginctl_seats()
|
||||
{
|
||||
local -a _sys_all_seats{,_descr}
|
||||
|
||||
_loginctl_all_seats
|
||||
compadd "$@" -a - _sys_all_seats
|
||||
for _ignore in $words[2,-1]; do
|
||||
_sys_all_seats[(i)$_ignore]=()
|
||||
_sys_all_seats_descr[(i)$_ignore:*]=()
|
||||
done
|
||||
|
||||
_describe -t systemd-seats seat _sys_all_seats_descr _sys_all_seats "$@"
|
||||
}
|
||||
for fun in seat-status show-seat terminate-seat ; do
|
||||
(( $+functions[_loginctl_$fun] )) || _loginctl_$fun()
|
||||
@ -36,8 +82,6 @@ done
|
||||
# Completion functions for ATTACH
|
||||
(( $+functions[_loginctl_attach] )) || _loginctl_attach()
|
||||
{
|
||||
_loginctl_all_seats
|
||||
|
||||
_arguments -w -C -S -s \
|
||||
':seat:_loginctl_seats' \
|
||||
'*:device:_files'
|
||||
@ -78,7 +122,7 @@ done
|
||||
if (( CURRENT == 1 )); then
|
||||
_describe -t commands 'loginctl command' _loginctl_cmds || compadd "$@"
|
||||
else
|
||||
local curcontext="$curcontext"
|
||||
local curcontext="$curcontext" _ignore
|
||||
|
||||
cmd="${${_loginctl_cmds[(r)$words[1]:*]%%:*}}"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user