summaryrefslogtreecommitdiffstats
path: root/shell-completion/bash/networkctl
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 03:50:40 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 03:50:40 +0000
commitfc53809803cd2bc2434e312b19a18fa36776da12 (patch)
treeb4b43bd6538f51965ce32856e9c053d0f90919c8 /shell-completion/bash/networkctl
parentAdding upstream version 255.5. (diff)
downloadsystemd-fc53809803cd2bc2434e312b19a18fa36776da12.tar.xz
systemd-fc53809803cd2bc2434e312b19a18fa36776da12.zip
Adding upstream version 256.upstream/256
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'shell-completion/bash/networkctl')
-rw-r--r--shell-completion/bash/networkctl28
1 files changed, 25 insertions, 3 deletions
diff --git a/shell-completion/bash/networkctl b/shell-completion/bash/networkctl
index db59a9c..6c9daa7 100644
--- a/shell-completion/bash/networkctl
+++ b/shell-completion/bash/networkctl
@@ -1,3 +1,4 @@
+# shellcheck shell=bash
# networkctl(1) completion -*- shell-script -*-
# SPDX-License-Identifier: LGPL-2.1-or-later
#
@@ -28,17 +29,32 @@ __get_links() {
networkctl list --no-legend --no-pager --all --full | { while read -r a b c; do echo " $b"; done; };
}
+__get_links_with_prefix() {
+ local i
+ for i in $(__get_links); do
+ echo "@$i"
+ done
+}
+
+__get_files() {
+ ls {/run,/usr/lib,/etc}/systemd/network/*.{network,netdev,link} 2>/dev/null
+}
+
_networkctl() {
local i verb comps
local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} words cword
local -A OPTS=(
- [STANDALONE]='-a --all -h --help --version --no-pager --no-legend -s --stats -l --full'
- [ARG]='-n --lines --json'
+ [STANDALONE]='-a --all -h --help --version --no-pager --no-legend -s --stats -l --full
+ --no-reload --runtime'
+ [ARG]='-n --lines --json --drop-in'
)
local -A VERBS=(
[STANDALONE]='label reload'
[LINKS]='status list lldp delete renew up down forcerenew reconfigure'
+ [FILES_OR_LINKS]='edit cat'
+ [FILES]='mask unmask'
+ [BOOL]='persistent-storage'
)
_init_completion || return
@@ -54,7 +70,7 @@ _networkctl() {
if __contains_word "$prev" ${OPTS[ARG]}; then
case $prev in
--json)
- comps=$(networkctl --json=help | sort 2>/dev/null)
+ comps=$(networkctl --json=help)
;;
*)
return 0
@@ -75,6 +91,12 @@ _networkctl() {
comps=''
elif __contains_word "$verb" ${VERBS[LINKS]}; then
comps=$( __get_links )
+ elif __contains_word "$verb" ${VERBS[FILES_OR_LINKS]}; then
+ comps=$( __get_files; __get_links_with_prefix )
+ elif __contains_word "$verb" ${VERBS[FILES]}; then
+ comps=$( __get_files )
+ elif __contains_word "$verb" ${VERBS[BOOL]}; then
+ comps=$( yes no )
fi
COMPREPLY=( $(compgen -W '$comps' -- "$cur") )