From 2dee3987d493aafc3340d6eed3f0d57cc60c3126 Mon Sep 17 00:00:00 2001 From: dadav <33197631+dadav@users.noreply.github.com> Date: Sat, 18 Apr 2020 10:59:08 +0200 Subject: [PATCH] add bash completion --- .../bash_completion.d/pwnagotchi_completion.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 builder/data/etc/bash_completion.d/pwnagotchi_completion.sh diff --git a/builder/data/etc/bash_completion.d/pwnagotchi_completion.sh b/builder/data/etc/bash_completion.d/pwnagotchi_completion.sh new file mode 100644 index 0000000..c919281 --- /dev/null +++ b/builder/data/etc/bash_completion.d/pwnagotchi_completion.sh @@ -0,0 +1,17 @@ +_show_complete() +{ + local cur prev opts node_names + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + cmd="${COMP_WORDS[@]:0:${#COMP_WORDS[@]}-1}" + if [[ ${cur} == -* ]] ; then + opts="$($cmd --help | tr ' ' '\n' | awk '/^ *-/{gsub("[^a-zA-Z0-9-]","",$1);print $1}')" + COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) + return 0 + fi + + opts="$($cmd --help | sed -n '/positional arguments:/ {n;p}' | tr ',' '\n' | awk '{gsub("[^a-zA-Z0-9-]", "", $1); print $1}')" + COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) +} + +complete -F _show_complete pwnagotchi