Skip to content

Commit

Permalink
add bash completion
Browse files Browse the repository at this point in the history
  • Loading branch information
dadav committed Apr 18, 2020
1 parent eb76cc7 commit 2dee398
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions builder/data/etc/bash_completion.d/pwnagotchi_completion.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 2dee398

Please sign in to comment.