summaryrefslogtreecommitdiffstats
path: root/completions/ss
diff options
context:
space:
mode:
Diffstat (limited to 'completions/ss')
-rw-r--r--completions/ss40
1 files changed, 21 insertions, 19 deletions
diff --git a/completions/ss b/completions/ss
index 4a27d51..e383fe5 100644
--- a/completions/ss
+++ b/completions/ss
@@ -1,41 +1,43 @@
# ss(8) completion -*- shell-script -*-
-_ss()
+_comp_cmd_ss()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
+ local noargopts='!(-*|*[fADF]*)'
+ # shellcheck disable=SC2254
case $prev in
- --help | --version | -!(-*)[hV])
+ --help | --version | -${noargopts}[hV])
return
;;
- --family | -!(-*)f)
- COMPREPLY=($(compgen -W 'unix inet inet6 link netlink' \
- -- "$cur"))
+ --family | -${noargopts}f)
+ _comp_compgen -- -W 'unix inet inet6 link netlink'
return
;;
- --query | -!(-*)A)
- local prefix=
- [[ $cur == *,* ]] && prefix="${cur%,*},"
- COMPREPLY=($(compgen -W '$("$1" --help | \
- command sed -e "s/|/ /g" -ne "s/.*QUERY := {\([^}]*\)}.*/\1/p")' \
- -- "${cur##*,}"))
- ((${#COMPREPLY[@]} == 1)) && COMPREPLY=(${COMPREPLY/#/$prefix})
+ --query | -${noargopts}A)
+ local queries=$("$1" --help |
+ command sed -e 's/|/ /g' -ne 's/.*QUERY := {\([^}]*\)}.*/\1/p')
+ _comp_delimited , -W '$queries'
return
;;
- --diag | --filter | -!(-*)[DF])
- _filedir
+ --diag | --filter | -${noargopts}[DF])
+ _comp_compgen_filedir
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
+ elif [[ $prev == state ]]; then
+ _comp_compgen -- -W 'all connected synchronized bucket big established
+ syn-sent syn-recv fin-wait-{1,2} time-wait closed close-wait
+ last-ack listening closing'
fi
} &&
- complete -F _ss ss
+ complete -F _comp_cmd_ss ss
# ex: filetype=sh