]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
zsh: amend completion for networkctl edit
authorRonan Pigott <ronan@rjp.ie>
Sun, 21 May 2023 20:33:22 +0000 (13:33 -0700)
committerLuca Boccassi <luca.boccassi@gmail.com>
Mon, 22 May 2023 11:14:04 +0000 (12:14 +0100)
shell-completion/zsh/_networkctl

index 24d118045d46441ed64bbd3e4242d5e05ad3a4e1..c7d1e3a3657924660ea8777005710218b92c191f 100644 (file)
@@ -10,6 +10,8 @@
             'lldp:Show Link Layer Discovery Protocol status'
             'label:Show address labels'
             'delete:Delete virtual netdevs'
+            'edit:Edit network configurations'
+            'cat:Cat network configurations'
             'up:Bring devices up'
             'down:Bring devices down'
             'renew:Renew dynamic configurations'
             local -a _links
             cmd="${${_networkctl_cmds[(r)$words[1]:*]%%:*}}"
             case $cmd in
-                (list|status|up|down|lldp|delete|renew|forcerenew|reconfigure)
-                    _links=( "${(foa)$(networkctl list --no-legend | awk 'BEGIN{OFS=":"} {sub(/[[ \t]+/, ""); print $2,$0}' 2>/dev/null)}" )
+                (list|status|up|down|cat|edit|lldp|delete|renew|forcerenew|reconfigure)
+                    for link in ${(f)"$(_call_program links networkctl list --no-legend)"}; do _links+=($link[(w)2]:$link); done
                     if [[ -n "$_links" ]]; then
-                         _describe -t links 'links' _links
+                        _describe -t links 'links' _links _links $( [[ $cmd == (edit|cat) ]] && print -- -P@ )
                     else
                         _message "no links"
                     fi
@@ -52,5 +54,7 @@ _arguments \
     '--no-legend[Do not print the column headers]' \
     {-h,--help}'[Show this help]' \
     '--version[Show package version]' \
+    '--drop-in=[Use the given drop-in file name]' \
+    '--no-reload[Do not reload the network manager state when editing]' \
     '--json[Shows output formatted as JSON]:format:_networkctl_get_json' \
     '*::networkctl commands:_networkctl_commands'