Back to Shell Autocompletion
complete, compopt, compgenCOMP_WORDS, COMPREPLY (out)bash-completionlineedit/compparse.{c,h} (~1300 lines) is a "simple parser for command line completion" that duplicates knowledge of the shell language. It doesn't use its own parser much, if at all.help complete shows help for the extensive completion builtin. Doesn't seem to understand the flags of its own builtins.share/completionAs usual, git is one of the biggest completions!
~/src/languages/yash-2.46/share/completion$ wc -l *|sort -n
...
497 git-config
541 tar
554 find
597 git-svn
657 INIT
759 git
850 svn
19921 total
TODO
complete builtinOil reuses its parser for autocompletion.
I haven't documented this fully, but here's one blog post:
Notes:
core/completion.py. RootCompleter::Matches() is the core logic, which is somewhat hairy, but much simpler and more compact than the equivalent other shells. See trail.tokens.Id.Expr_Dummy. This is a dummy token that helps parse incomplete code (I honestly don't remember the details, but I recall that a lot of things fell out nicely with this little mechanism.)Bugs