Bash Completion

Since picoLisp-3.0.9 there is support for Bash completion.

While it is not precisely the absolute killer-feature, bash completion is quite handy when developing PicoLisp applications from the shell command line.

If you installed PicoLisp locally (i.e. not from a distribution package), you need to copy two files
   $ cp lib/complete.l /usr/lib/picolisp/lib/
   $ cp lib/bash_completion /usr/share/bash-completion/completions/pil
As ever, source . /etc/bash_completion in your .bashrc

Per default, if you hit the TAB key during command line input, Bash completes things it knows about, like commands and path names.

PicoLisp - in addition to normal path/file name arguments - accepts two particular types of arguments:
  1. If the argument's first character is '-', then the rest of that argument is taken as a Lisp function call (without the surrounding parentheses).
  2. If the argument's first character is '@', then it is interpreted as a path into the interpreter's installation directory.

For (1), the expansion actually searches all built-in function names of the given invocation. For example, entering
   $ pil -ver
and then hitting TAB will expand to "-version".

The expansion also honors single or double quotes, to allow for function arguments:
   $ pil -'pri
   $ pil -"pri
This expands to the printing functions.

For (2), the intended path name is properly expanded. This works regardless of whether it is a global or a local installation, as it always searches the invoked interpreter's environment.
   $ pil @lib/xh
   $ <somePath>/pil @lib/xh
both will expand to "@lib/xhtml.l".

As an extra goody, an empty argument expands to '+' (the trailing debug flag - perhaps the most often needed command line argument).

29dec20    abu