git-meta
git-meta copied to clipboard
FR: Bash Autocompletion
Tab should recommend and autocomplete for commands and options
bash and zsh provide tab-completion through bash scripts.
- git uses this (natively) through a (large) bash script.
- npm decided to use this a little differently, they have the bash script call npm again, but pass in a special flag. When the flag is seen, the code path will change to give recommendations (stdout). bash script. This script will print if you just type
npm completioninto a console - omelette and node-tab-tab are simply wrappers similar to npm completion. When a special flag is seen, they simply emit a signal which can be received in the code
In other words, the process is:
- Generate simple bash script which parses environment variables into "command line arguments" and calls git-meta again with a special flag
- Get this bash script added to bash_completion, or manual install.
- When user presses tab, bash script called git-meta, git-meta sees the special flag and instead of following code-paths, determines what are possible arguments and returns them to stdout