]> git.ipfire.org Git - thirdparty/systemd.git/blob - shell-completion/zsh/_networkctl
Merge pull request #11827 from keszybz/pkgconfig-variables
[thirdparty/systemd.git] / shell-completion / zsh / _networkctl
1 #compdef networkctl
2 # SPDX-License-Identifier: LGPL-2.1+
3
4 (( $+functions[_networkctl_commands] )) ||
5 _networkctl_commands(){
6 local -a _networkctl_cmds
7 _networkctl_cmds=(
8 'list:List existing links'
9 'status:Show information about the specified links'
10 'lldp:Show Link Layer Discovery Protocol status'
11 'label:Show address labels'
12 )
13 if (( CURRENT == 1 )); then
14 _describe -t commands 'networkctl command' _networkctl_cmds
15 else
16 local curcontext="$curcontext"
17 local -a _links
18 cmd="${${_networkctl_cmds[(r)$words[1]:*]%%:*}}"
19 if [ $cmd = "status" ]; then
20 _links=( "${(foa)$(networkctl list --no-legend | awk 'BEGIN{OFS=":"} {sub(/[[ \t]+/, ""); print $2,$0}' 2>/dev/null)}" )
21 if [[ -n "$_links" ]]; then
22 _describe -t links 'links' _links
23 else
24 _message "no links"
25 fi
26 else
27 _message "no more options"
28 fi
29 fi
30 }
31
32 _arguments \
33 {-a,--all}'[Show all links with status]' \
34 '--no-pager[Do not pipe output into a pager]' \
35 '--no-legend[Do not print the column headers]' \
36 {-h,--help}'[Show this help]' \
37 '--version[Show package version]' \
38 '*::networkctl commands:_networkctl_commands'