CLI Magic: Bash complete (Linux.com)
CLI Magic: Bash complete (Linux.com)
Posted May 12, 2006 14:31 UTC (Fri) by dododge (guest, #2870)Parent article: CLI Magic: Bash complete (Linux.com)
A potential downside to bash's programmable completion is when a
distribution has pre-loaded it with a ton of rules that override
normal completion. For example someone has preconfigured
a rule so that bash will only complete *.txt
files for the
command you're trying to run, but the file you want to use doesn't
match that pattern. I forget where I ran into this situation,
but I've seen it in action and "annoying" doesn't even begin to
describe it.
The most interesting auto-completion system I've ever used was rk
, the "Reactive
Keyboard". This was an add-on that wrapped your shell session and intercepted command-line input. It was useful
with e.g. the old Sun csh because it gave you things like a browsable
history and emacs bindings. Its big trick, though, is that it could predict what you
were going to type next based on prior input. And since it was
sitting on top of the entire shell session it actually kept running
when you entered other command-line tools such as "ftp" and could
then predict your next ftp commands such as "cd pub" or "binary".
I recall it being pretty good at the predictive stuff, and very easy
to work with.
The downside was that it could end up using several megabytes of RAM to hold the predictive history, and back in those days it really hurt for each shell to be eating 8M.
It was apparently someone's thesis project and there was even a book published about it, but the software pretty much died sometime in the mid-90s. You can still find old versions of the sourcecode lying around if you look really hard, but none of the ones I've seen are Linux-ready.
Posted May 12, 2006 16:08 UTC (Fri)
by liljencrantz (guest, #28458)
[Link]
In my experience, it is generally better to include a bit too many completions instead of a bit too few, but not by a wide margin.
Writing completion rules is harder than you'd think. It is extremely hard to foresee all reasonable usecases for a non-trivial command. If you limit the completions too much, you'll end up with the frustration of spelling out things shat 'should' be completable, if you have too many completions, they will be worthless because there will be too much noise.CLI Magic: Bash complete (Linux.com)