Learning and exploring Bash programmable completion.
Programmable completion has always been daunting to me. The scripts in this directory have let me incrementally understand the topic by exploring interactive completion, non-interactive completion, and then finally the mechanisms of the 'bash-completion' library.
- Start with the essentials
-
. programmable-completion-example.bash
- Study the source code, exercise the completions, and experiment for yourself.
-
- Graduate to non-interactive (i.e. headless, i.e. programmatic) completion
-
./programmable-completion-example-non-interactive.bash
- This script is interesting because it simulates a completion environment. This is useful for automated testing.
-
- Graduate to 'bash-completion'
-
env -i /opt/homebrew/bin/bash --noprofile bash-completion-example-non-interactive.bash
- This was pretty difficult. However, the 'bash-completion' source code is well documented and with the help of an LLM you have a chance to actually tease apart Bash code.
-
General clean-ups, TODOs and things I wish to implement for this project:
- DONE Figure out how to autoload a completion script.
- DONE Consider file renames for consistency
- DONE Completions when no arguments. Am I not simulating the comp env vars correctly?