]> git.proxmox.com Git - systemd.git/blob - shell-completion/zsh/_loginctl
Imported Upstream version 208
[systemd.git] / shell-completion / zsh / _loginctl
1 #compdef loginctl
2
3 _loginctl_all_sessions(){_sys_all_sessions=($(loginctl list-sessions | { while read a b; do echo " $a"; done; }) )}
4 _loginctl_all_users() {_sys_all_users=( $(loginctl list-users | { while read a b; do echo " $a"; done; }) )}
5 _loginctl_all_seats() {_sys_all_seats=( $(loginctl list-seats | { while read a b; do echo " $a"; done; }) )}
6
7 # Completion functions for SESSIONS
8 for fun in session-status show-session activate lock-session unlock-session terminate-session kill-session ; do
9 (( $+functions[_loginctl_$fun] )) || _loginctl_$fun()
10 {
11 _loginctl_all_sessions
12 compadd "$@" -a - _sys_all_sessions
13 }
14 done
15
16 # Completion functions for USERS
17 for fun in user-status show-user enable-linger disable-linger terminate-user kill-user ; do
18 (( $+functions[_loginctl_$fun] )) || _loginctl_$fun()
19 {
20 _loginctl_all_users
21 compadd "$@" -a - _sys_all_users
22 }
23 done
24
25 # Completion functions for SEATS
26 (( $+functions[_loginctl_seats] )) || _loginctl_seats()
27 {
28 _loginctl_all_seats
29 compadd "$@" -a - _sys_all_seats
30 }
31 for fun in seat-status show-seat terminate-seat ; do
32 (( $+functions[_loginctl_$fun] )) || _loginctl_$fun()
33 { _loginctl_seats }
34 done
35
36 # Completion functions for ATTACH
37 (( $+functions[_loginctl_attach] )) || _loginctl_attach()
38 {
39 _loginctl_all_seats
40
41 _arguments -w -C -S -s \
42 ':seat:_loginctl_seats' \
43 '*:device:_files'
44 }
45
46 # no loginctl completion for:
47 # [STANDALONE]='list-sessions list-users list-seats flush-devices'
48
49 (( $+functions[_loginctl_command] )) || _loginctl_command()
50 {
51 local -a _loginctl_cmds
52 _loginctl_cmds=(
53 "list-sessions:List sessions"
54 "session-status:Show session status"
55 "show-session:Show properties of one or more sessions"
56 "activate:Activate a session"
57 "lock-session:Screen lock one or more sessions"
58 "unlock-session:Screen unlock one or more sessions"
59 "terminate-session:Terminate one or more sessions"
60 "kill-session:Send signal to processes of a session"
61 "list-users:List users"
62 "user-status:Show user status"
63 "show-user:Show properties of one or more users"
64 "enable-linger:Enable linger state of one or more users"
65 "disable-linger:Disable linger state of one or more users"
66 "terminate-user:Terminate all sessions of one or more users"
67 "kill-user:Send signal to processes of a user"
68 "list-seats:List seats"
69 "seat-status:Show seat status"
70 "show-seat:Show properties of one or more seats"
71 "attach:Attach one or more devices to a seat"
72 "flush-devices:Flush all device associations"
73 "terminate-seat:Terminate all sessions on one or more seats"
74 )
75
76 if (( CURRENT == 1 )); then
77 _describe -t commands 'loginctl command' _loginctl_cmds || compadd "$@"
78 else
79 local curcontext="$curcontext"
80
81 cmd="${${_loginctl_cmds[(r)$words[1]:*]%%:*}}"
82
83 if (( $#cmd )); then
84 curcontext="${curcontext%:*:*}:loginctl-${cmd}:"
85
86 _call_function ret _loginctl_$cmd || _message 'no more arguments'
87 else
88 _message "unknown loginctl command: $words[1]"
89 fi
90 return ret
91 fi
92 }
93
94
95 _arguments -s \
96 {-h,--help}'[Show help]' \
97 '--version[Show package version]' \
98 \*{-p+,--property=}'[Show only properties by this name]:unit property' \
99 {-a,--all}'[Show all properties, including empty ones]' \
100 '--kill-who=[Who to send signal to]:killwho:(main control all)' \
101 {-s+,--signal=}'[Which signal to send]:signal:_signals' \
102 '--no-ask-password[Do not ask for system passwords]' \
103 {-H+,--host=}'[Show information for remote host]:userathost:_sd_hosts_or_user_at_host' \
104 {-P,--privileged}'[Acquire privileges before execution]' \
105 '--no-pager[Do not pipe output into a pager]' \
106 '*::loginctl command:_loginctl_command'