Debian Codegraph @

contrib/zsh-completion

raw
1 #compdef netctl netctl-auto wifi-menu
2
3
4 (( $+function[_wireless_interfaces] )) ||
5 _wireless_interfaces() {
6 local interfaces
7 interfaces=(/sys/class/net/*/wireless(/))
8 print -l ${${(R)interfaces%/wireless}:t}
9 }
10
11
12 (( $+function[_netctl_command] )) ||
13 _netctl_command() {
14 [[ $words[1] = (start|stop|restart|switch-to|is-active|status|enable|disable|reenable|is-enabled|edit|wait-online) ]] &&
15 compadd "${(f)$(find -L /etc/netctl -maxdepth 1 -type f -not -name '.*' -not -name '*~' -not -name $'*\n*' -not -name '*.action' -not -name '*.conf' -not -name '*.service' -printf '%f\n')}"
16 }
17
18
19 _netctl_commands() {
20 local -a _commands
21 _commands=(
22 'list:List available profiles'
23 'store:Save which profiles are active'
24 'restore:Load saved profiles'
25 'stop-all:Stops all profiles'
26 'start:Start a profile'
27 'stop:Stop a profile'
28 'restart:Restart a profile'
29 'switch-to:Switch to a profile'
30 'is-active:Check whether a profile is active'
31 'status:Show runtime status of a profile'
32 'enable:Enable the systemd unit for a profile'
33 'disable:Disable the systemd unit for a profile'
34 'reenable:Reenable the systemd unit for a profile'
35 'is-enabled:Check whether a profile is enabled'
36 'edit:Edit a profile'
37 'wait-online:Wait for a profile to finish connecting'
38 )
39 _describe "netctl commands" _commands
40 }
41
42 _netctl-auto_commands() {
43 local -a _commands
44 _commands=(
45 'list:List available profiles'
46 'switch-to:Switch to a profile, enable it if necessary'
47 'is-active:Check whether a profile is active'
48 'enable:Enable a profile for automatic selection'
49 'disable:Disable a profile temporarily for automatic selection'
50 'enable-all:Enable all profiles for automatic selection'
51 'disable-all:Disable all profiles temporarily for automatic selection'
52 'is-enabled:Check whether a profile is enabled'
53 )
54 _describe "netctl-auto commands" _commands
55 }
56
57 case $service in
58 netctl|netctl-auto)
59 case $CURRENT in
60 2)
61 _arguments \
62 '(- :)--version[display version information]' \
63 '(- :)--help[display help message]' \
64 '(-)::netctl commands:_${service}_commands'
65 ;;
66 3)
67 shift words
68 [[ $words[1] != -* ]] &&
69 curcontext="${curcontext%:*}-${words[1]}:" _netctl_command
70 ;;
71 esac
72 ;;
73 wifi-menu)
74 (( CURRENT == 2 )) && compadd "${(f)$(_wireless_interfaces)}"
75 ;;
76 esac