Demonstrate how to write autocomplete scripts
TODO:
- register and unregister completions?
- Do completions already exist for script?
# source the completion script
. ./example-completion.bash
# or
source ./example-completion.bash # print options
./test-script.sh <tab> <tab># look at the internal variables that can be used to determine output
export COMPLETION_DEBUG="true"
./test-script.sh <tab> <tab>
unset COMPLETION_DEBUGWe assign a completion function and then use it to print out a list of options.
man builtins
/compgen./test_script.sh --action=ls <tab>
./test_script.sh --action=ls -f=-l
./test_script.sh --action=ls --flag=-la
./test_script.sh --action=ps <tab>
./test_script.sh --action=ls --flag=-aux
# gets completion options from the script
./test_script.sh --action=ls --flag=-la <tab> . ./remove-completions.bash
# or
source ./remove-completions.bash ./test-script.sh <tab> <tab>