summaryrefslogtreecommitdiffstats
path: root/completions/sh
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--completions/sh25
-rw-r--r--completions/sha256sum38
-rw-r--r--completions/shellcheck50
3 files changed, 76 insertions, 37 deletions
diff --git a/completions/sh b/completions/sh
index 5624ffa..5581bcc 100644
--- a/completions/sh
+++ b/completions/sh
@@ -1,36 +1,35 @@
# POSIX sh(1) completion -*- shell-script -*-
-_sh()
+_comp_cmd_sh()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-c)
return
;;
-o | +o)
- COMPREPLY=($(compgen -W 'allexport errexit ignoreeof monitor
- noclobber noglob noexec nolog notify nounset verbose vi
- xtrace' -- "$cur"))
+ _comp_compgen -- -W 'allexport errexit ignoreeof monitor noclobber
+ noglob noexec nolog notify nounset verbose vi xtrace'
return
;;
esac
local opts="-a -b -C -e -f -h -i -m -n -o -u -v -x"
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W "$opts -c -s" -- "$cur"))
+ _comp_compgen -- -W "$opts -c -s"
return
elif [[ $cur == +* ]]; then
- COMPREPLY=($(compgen -W "${opts//-/+}" -- "$cur"))
+ _comp_compgen -- -W "${opts//-/+}"
return
fi
- local args ext=
- _count_args "" "@(-c|[-+]o)"
- ((args == 1)) && ext="sh"
- _filedir $ext
+ local REPLY ext=
+ _comp_count_args -a "@(-c|[-+]o)"
+ ((REPLY == 1)) && ext="sh"
+ _comp_compgen_filedir $ext
} &&
- complete -F _sh sh
+ complete -F _comp_cmd_sh sh
# ex: filetype=sh
diff --git a/completions/sha256sum b/completions/sha256sum
new file mode 100644
index 0000000..adef1cd
--- /dev/null
+++ b/completions/sha256sum
@@ -0,0 +1,38 @@
+# bash completion for sha256(1) and friends -*- shell-script -*-
+
+_comp_cmd_sha256sum()
+{
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
+
+ case $prev in
+ -h | --help | --version)
+ return
+ ;;
+ esac
+
+ [[ $was_split ]] && return
+
+ if [[ $cur == -* ]]; then
+ _comp_complete_longopt "$@"
+ return
+ fi
+
+ local sumtype=${1##*/}
+ sumtype=${sumtype%sum}
+
+ local opt
+ for opt in "${words[@]}"; do
+ if [[ $opt == -@(c|-check) ]]; then
+ _comp_compgen_filedir "$sumtype"
+ return
+ fi
+ done
+
+ local files
+ _comp_compgen -v files filedir &&
+ _comp_compgen -- -X "*.$sumtype" -W '"${files[@]}"'
+} &&
+ complete -F _comp_cmd_sha256sum b2sum md5sum sha{,1,224,256,384,512}sum
+
+# ex: filetype=sh
diff --git a/completions/shellcheck b/completions/shellcheck
index 6421d7b..dc14c07 100644
--- a/completions/shellcheck
+++ b/completions/shellcheck
@@ -1,63 +1,65 @@
# bash completion for shellcheck(1) -*- shell-script -*-
-_shellcheck_optarg()
+_comp_cmd_shellcheck__optarg()
{
local args=$("$1" --help 2>&1 |
- command sed -e 's/,/ /g' -ne 's/^.*'$2'\>.*(\([^)]*\)).*/\1/p')
- COMPREPLY+=($(compgen -W '$args' -- "$cur"))
+ command sed -e 's/,/ /g' -ne 's/^.*'"$2"'\>.*(\([^)]*\)).*/\1/p')
+ _comp_compgen -a -- -W '$args'
}
-_shellcheck()
+_comp_cmd_shellcheck()
{
- 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='!(-*|*[eifCsoPW]*)'
+ # shellcheck disable=SC2254
case $prev in
- --version | -!(-*)V*)
+ --version | -${noargopts}V*)
return
;;
- --exclude | --include | -!(-*)[ei])
+ --exclude | --include | -${noargopts}[ei])
return
;;
- --format | -!(-*)f)
+ --format | -${noargopts}f)
local args=$("$1" --format=nonexistent-format /dev/null 2>&1 |
command sed -ne '/^Supported formats/,//p' |
command sed -ne '/^[[:space:]]/p')
- COMPREPLY=($(compgen -W '$args' -- "$cur"))
+ _comp_compgen -- -W '$args'
return
;;
- --color | -!(-*)C)
- _shellcheck_optarg "$1" --color
+ --color | -${noargopts}C)
+ _comp_cmd_shellcheck__optarg "$1" --color
return
;;
- --shell | -!(-*)s)
- _shellcheck_optarg "$1" --shell
+ --shell | -${noargopts}s)
+ _comp_cmd_shellcheck__optarg "$1" --shell
return
;;
- --enable | -!(-*)o)
- COMPREPLY=($(compgen -W 'all' -- "$cur")) # TODO others?
+ --enable | -${noargopts}o)
+ _comp_compgen -- -W 'all' # TODO others?
return
;;
- --source-path | -!(-*)P)
- _filedir -d
- COMPREPLY+=($(compgen -W 'SCRIPTDIR' -- "$cur"))
+ --source-path | -${noargopts}P)
+ _comp_compgen_filedir -d
+ _comp_compgen -a -- -W 'SCRIPTDIR'
return
;;
- --wiki-link-count | -!(-*)W)
+ --wiki-link-count | -${noargopts}W)
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
- _filedir
+ _comp_compgen_filedir
} &&
- complete -F _shellcheck shellcheck
+ complete -F _comp_cmd_shellcheck shellcheck
# ex: filetype=sh