git-meta icon indicating copy to clipboard operation
git-meta copied to clipboard

FR: Bash Autocompletion

Open jhedwardyang opened this issue 9 years ago • 1 comments

Tab should recommend and autocomplete for commands and options

jhedwardyang avatar Apr 19 '16 19:04 jhedwardyang

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 completion into 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:

  1. Generate simple bash script which parses environment variables into "command line arguments" and calls git-meta again with a special flag
  2. Get this bash script added to bash_completion, or manual install.
  3. 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

jhedwardyang avatar Apr 25 '16 01:04 jhedwardyang