summaryrefslogtreecommitdiffstats
path: root/completions
diff options
context:
space:
mode:
Diffstat (limited to 'completions')
-rw-r--r--completions/Makefile.am1
-rw-r--r--completions/_rg8
-rw-r--r--completions/curl5
-rw-r--r--completions/ip189
-rw-r--r--completions/tar2
-rw-r--r--completions/xmllint2
-rw-r--r--completions/xmlwf2
7 files changed, 175 insertions, 34 deletions
diff --git a/completions/Makefile.am b/completions/Makefile.am
index 8f11291..ed1f215 100644
--- a/completions/Makefile.am
+++ b/completions/Makefile.am
@@ -377,6 +377,7 @@ bashcomp_DATA = 2to3 \
_reptyr \
resolvconf \
_rfkill \
+ _rg \
ri \
rmlist \
rmmod \
diff --git a/completions/_rg b/completions/_rg
new file mode 100644
index 0000000..4129371
--- /dev/null
+++ b/completions/_rg
@@ -0,0 +1,8 @@
+# 3rd party completion loader for commands emitting -*- shell-script -*-
+# their completion using "$cmd --generate complete-bash".
+#
+# This serves as a fallback in case the completion is not installed otherwise.
+
+eval -- "$("$1" --generate complete-bash 2>/dev/null)"
+
+# ex: filetype=sh
diff --git a/completions/curl b/completions/curl
index 6cbbca4..55865c0 100644
--- a/completions/curl
+++ b/completions/curl
@@ -22,7 +22,7 @@ _comp_cmd_curl()
--happy-eyeballs-timeout-ms | --hostpubmd5 | --keepalive-time | \
--limit-rate | --local-port | --login-options | --mail-auth | \
--mail-from | --mail-rcpt | --max-filesize | --max-redirs | \
- --max-time | --pass | --proto | --proto-default | --proto-redir | \
+ --max-time | --pass | --proto | --proto-redir | \
--proxy-ciphers | --proxy-pass | --proxy-service-name | \
--proxy-tls13-ciphers | --proxy-tlspassword | --proxy-tlsuser | \
--proxy-user | --proxy1.0 | --quote | --range | --referer | \
@@ -127,6 +127,9 @@ _comp_cmd_curl()
_comp_compgen_known_hosts -- "$cur"
return
;;
+ --proto-default)
+ _comp_compgen_split "$("$1" --version 2>/dev/null | command sed -e '/Protocols/!d' -e 's/Protocols://')"
+ ;;
--pubkey)
_comp_compgen -x ssh identityfile pub
return
diff --git a/completions/ip b/completions/ip
index 511f206..09bec5b 100644
--- a/completions/ip
+++ b/completions/ip
@@ -8,10 +8,45 @@ _comp_cmd_ip__iproute2_etc()
_comp_cmd_ip__netns()
{
- _comp_compgen_split -- "$(
+ local unquoted
+ _comp_split -l unquoted "$(
{
${1-ip} -c=never netns list 2>/dev/null || ${1-ip} netns list
- } | _comp_awk '{print $1}'
+ } | command sed -e 's/ (.*//'
+ )"
+ # namespace names can have spaces, so we quote all of them if needed
+ local ns quoted=()
+ for ns in "${unquoted[@]}"; do
+ local namespace
+ printf -v namespace '%q' "$ns"
+ quoted+=("$namespace")
+ done
+ ((${#quoted[@]})) && _comp_compgen -- -W '"${quoted[@]}"'
+}
+
+_comp_cmd_ip__link_types()
+{
+ _comp_compgen_split -- "$(
+ {
+ ${1-ip} -c=never link help || ${1-ip} link help
+ } 2>&1 | command sed -e \
+ '/TYPE := /,/}/!d' -e \
+ 's/.*{//' -e \
+ 's/}.*//' -e \
+ 's/|/ /g'
+ )"
+}
+
+_comp_cmd_ip__neigh_states()
+{
+ _comp_compgen_split -- "$(
+ {
+ ${1-ip} -c=never neigh help || ${1-ip} neigh help
+ } 2>&1 | command sed -e \
+ '/STATE := /,/}/!d' -e \
+ 's/.*{//' -e \
+ 's/}.*//' -e \
+ 's/|/ /g'
)"
}
@@ -47,7 +82,7 @@ _comp_cmd_ip()
[[ ${words[subcword]} == -b?(atch) ]] && return
[[ $has_cmd ]] && subcmd=${words[subcword]} && break
[[ ${words[subcword]} != -* &&
- ${words[subcword - 1]} != -@(f?(amily)|rc?(vbuf)) ]] &&
+ ${words[subcword - 1]} != -@(f?(amily)|rc?(vbuf)|n?(etns)) ]] &&
cmd=${words[subcword]} has_cmd=set
done
@@ -66,7 +101,7 @@ _comp_cmd_ip()
*)
_comp_compgen_split -- "help $(
{
- $1 -c=never help || $1 help
+ "$1" -c=never help || "$1" help
} 2>&1 | command sed -e \
'/OBJECT := /,/}/!d' -e \
's/.*{//' -e \
@@ -87,19 +122,12 @@ _comp_cmd_ip()
# TODO
;;
delete)
- case $((cword - subcword)) in
- 1)
- _comp_compgen_available_interfaces
- ;;
- 2)
- _comp_compgen -- -W 'type'
- ;;
- 3)
- [[ $prev == type ]] &&
- _comp_compgen -- -W 'vlan veth vcan dummy ifb
- macvlan can'
- ;;
- esac
+ if [[ $prev == type ]]; then
+ _comp_cmd_ip__link_types "$1"
+ else
+ _comp_compgen_available_interfaces
+ _comp_compgen -a -- -W 'type'
+ fi
;;
set)
if ((cword - subcword == 1)); then
@@ -132,9 +160,20 @@ _comp_cmd_ip()
_comp_cmd_ip__iproute2_etc group
fi
;;
+ property)
+ if ((cword - 1 == subcword)); then
+ _comp_compgen -- -W 'add del'
+ elif [[ $prev == dev ]]; then
+ _comp_compgen_available_interfaces
+ elif [[ $prev == altname ]]; then
+ return
+ else
+ _comp_compgen -- -W 'dev altname'
+ fi
+ ;;
*)
((cword == subcword)) &&
- _comp_compgen -- -W 'help add delete set show'
+ _comp_compgen -- -W 'help add delete set show property'
;;
esac
;;
@@ -164,11 +203,13 @@ _comp_cmd_ip()
_comp_compgen_available_interfaces
_comp_compgen -a -- -W 'dev scope to label dynamic
permanent tentative deprecated dadfailed temporary
- primary secondary up'
+ primary secondary up type'
elif [[ $prev == dev ]]; then
_comp_compgen_available_interfaces
elif [[ $prev == scope ]]; then
_comp_cmd_ip__iproute2_etc rt_scopes
+ elif [[ $prev == type ]]; then
+ _comp_cmd_ip__link_types "$1"
fi
;;
*)
@@ -181,13 +222,16 @@ _comp_cmd_ip()
addrlabel)
case $subcmd in
- list | add | del | flush)
+ add | del)
if [[ $prev == dev ]]; then
_comp_compgen_available_interfaces
+ elif [[ $prev == prefix || $prev == label ]]; then
+ : # TODO - Is there a way to complete these?
else
- : # TODO
+ _comp_compgen -- -W 'dev prefix label'
fi
;;
+ list | flush | help) ;;
*)
((cword == subcword)) &&
_comp_compgen -- -W 'help list add del flush'
@@ -211,14 +255,14 @@ _comp_cmd_ip()
if [[ $prev == via ]]; then
_comp_compgen_split -- "$(
{
- $1 -c=never r 2>/dev/null || $1 r
+ "$1" -c=never r 2>/dev/null || "$1" r
} | command sed -ne \
's/.*via \([0-9.]*\).*/\1/p'
)"
elif [[ $prev == "$subcmd" ]]; then
_comp_compgen_split -- "table default $(
{
- $1 -c=never r 2>/dev/null || $1 r
+ "$1" -c=never r 2>/dev/null || "$1" r
} | cut -d ' ' -f 1
)"
elif [[ $prev == dev ]]; then
@@ -274,14 +318,62 @@ _comp_cmd_ip()
;;
esac
;;
+ stats)
+ case "$subcmd" in
+ show)
+ if [[ $prev == dev ]]; then
+ _comp_compgen_available_interfaces
+ elif [[ $prev == group ]]; then
+ _comp_compgen -- -W "$(
+ # stats command was added after color, should always have it
+ "$1" -c=never stats help 2>&1 |
+ command sed -e \
+ '/^GROUP := /,/}/!d' -e \
+ 's/^GROUP := //g' -e \
+ '/:=/d' -e \
+ 's/[{}|]//g'
+ )"
+ elif [[ $prev == subgroup || $prev == suite ]]; then
+ : # TODO: complete subgroup and suite
+ else
+ _comp_compgen -- -W 'dev group subgroup suite'
+ fi
+ ;;
+ set)
+ if [[ $prev == dev ]]; then
+ _comp_compgen_available_interfaces
+ elif [[ $prev == l3_stats ]]; then
+ _comp_compgen -- -W 'on off'
+ else
+ _comp_compgen -- -W 'dev l3_stats'
+ fi
+ ;;
+ *)
+ _comp_compgen -- -W 'show set help'
+ ;;
+ esac
+ ;;
- neigh)
+ n | neigh | neighbor | neighbour)
case $subcmd in
add | del | change | replace)
# TODO
;;
show | flush)
- # TODO
+ case "$prev" in
+ nud)
+ _comp_cmd_ip__neigh_states "$1"
+ ;;
+ dev)
+ _comp_compgen_available_interfaces
+ ;;
+ nomaster | proxy | to | vrf) # TODO - Maybe we can complete vrf here?
+ :
+ ;;
+ *)
+ _comp_compgen -- -W 'proxy to nud vrf dev nomaster'
+ ;;
+ esac
;;
*)
((cword == subcword)) &&
@@ -306,7 +398,7 @@ _comp_cmd_ip()
esac
;;
- tunnel)
+ tun | tunnel)
case $subcmd in
show) ;;
@@ -369,24 +461,57 @@ _comp_cmd_ip()
esac
;;
- netns)
+ net | netns)
case $subcmd in
list | monitor) ;;
add | identify | list-id)
# TODO
;;
- delete | exec | pids | set)
+ delete | pids | set)
[[ $prev == "$subcmd" ]] && _comp_cmd_ip__netns "$1"
;;
+ exec)
+ local all_offset=0 i
+ for ((i = 1; i <= cword; i++)); do
+ case ${words[i]} in
+ -a | -all)
+ all_offset=1
+ break
+ ;;
+ esac
+ done
+ if [[ $prev == "$subcmd" && $all_offset != 1 ]]; then
+ _comp_cmd_ip__netns "$1"
+ else
+ local offset
+ offset="$((subcword + 2 - all_offset))"
+ _comp_command_offset "$offset"
+ fi
+ ;;
*)
((cword == subcword)) &&
- _comp_compgen -- -W 'help add delete exec identify list
+ _comp_compgen -- -W 'help add attach delete exec identify list
list-id monitor pids set'
;;
esac
;;
+ netconf)
+ case $subcmd in
+ show)
+ if ((cword == subcword + 1)); then
+ _comp_compgen -- -W 'dev'
+ elif [[ $prev == dev ]]; then
+ _comp_compgen_available_interfaces
+ fi
+ ;;
+ *)
+ ((cword == subcword)) && _comp_compgen -- -W 'help show'
+ ;;
+ esac
+ ;;
+
xfrm)
case $subcmd in
state | policy | monitor)
@@ -394,10 +519,14 @@ _comp_cmd_ip()
;;
*)
((cword == subcword)) &&
- _comp_compgen -- -W 'state policy monitor'
+ _comp_compgen -- -W 'help state policy monitor'
;;
esac
;;
+ help) ;;
+ *)
+ _comp_compgen -- -W 'help'
+ ;;
esac
} &&
complete -F _comp_cmd_ip ip
diff --git a/completions/tar b/completions/tar
index 83a4073..b11bd9b 100644
--- a/completions/tar
+++ b/completions/tar
@@ -31,7 +31,7 @@
# FIXME: timeout on tarball listing
# FIXME: cache 'tar --help' parsing results into global variables
# FIXME: at least 'tar -<tab>' should show some helping text (apart from just
-# pure option advices)
+# pure option advice)
# FIXME: short option completion should be more intuitive
# - verbose mode option should be advised multiple times
# - mode option should be advised only once
diff --git a/completions/xmllint b/completions/xmllint
index 57445bb..e424840 100644
--- a/completions/xmllint
+++ b/completions/xmllint
@@ -46,7 +46,7 @@ _comp_cmd_xmllint()
return
fi
- _comp_compgen_filedir '@(*ml|htm|svg?(z)|xs[dl]|rng|wsdl|jnlp|tld|dbk|docbook|page)?(.gz)'
+ _comp_compgen_filedir '@(*ml|htm|svg?(z)|xs[dl]|rng|wsdl|jnlp|tld|dbk|docbook|page|rss)?(.gz)'
} &&
complete -F _comp_cmd_xmllint xmllint
diff --git a/completions/xmlwf b/completions/xmlwf
index d047ee1..201734f 100644
--- a/completions/xmlwf
+++ b/completions/xmlwf
@@ -24,7 +24,7 @@ _comp_cmd_xmlwf()
return
fi
- _comp_compgen_filedir '@(*ml|htm|svg|xs[dl]|rng|wsdl|jnlp|tld|dbk|docbook|page)'
+ _comp_compgen_filedir '@(*ml|htm|svg|xs[dl]|rng|wsdl|jnlp|tld|dbk|docbook|page|rss)'
} &&
complete -F _comp_cmd_xmlwf xmlwf