secret/argz/argz.sh
Adrien Gallouët 7417bf0ee0 Import code
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-04-24 06:55:38 +00:00

13 lines
444 B
Bash

_argz() {
local last opts
last="${COMP_WORDS[COMP_CWORD]}"
COMP_WORDS[COMP_CWORD]="help"
opts="$("${COMP_WORDS[@]}" 2>/dev/null | awk '{print $1}' )"
case "$opts" in
'') ;;
CMD) mapfile -t COMPREPLY < <(compgen -A command -- "$last") ;;
DIR) mapfile -t COMPREPLY < <(compgen -A dir -- "$last") ;;
FILE) mapfile -t COMPREPLY < <(compgen -A file -- "$last") ;;
*) mapfile -t COMPREPLY < <(compgen -W "$opts" -- "$last") ;;
esac
}