A surprising benefit of command/program completion in my shell
I've recently been experimenting with a variant of my usual shell
that extends its general (filename) completion
to also specifically complete program names from your $PATH
. Of
course this is nothing new in general in shells; most shells that
have readline style completion at all have added command completion
as well. But it's new to me, so the experience has been interesting.
Of course the obvious benefit of command completion is that it makes
it less of a pain to deal with long command names. In the old days
this wasn't issue because Unix didn't have very many long command
names, but those days are long over by now. There are still a few
big new things that have short names, such as git
and go
, but
many other programs and systems give themselves increasingly long
and annoying binary names. Of course you can give regularly used
programs short aliases via symlinks or cover scripts, but that's
only really worth it in some cases. Program completion covers
everything.
(An obvious offender here is Google Chrome, which has the bland
name of google-chrome
or even google-chrome-stable
. I have an
alias or two for that.)
But command completion turned out to have a much more surprising
benefit for me: it's removed a lot of guesswork about what exactly
a program is called, especially for my own little scripts and
programs. If I use a program regularly I remember its full name,
but if I don't I used to have to play a little game of 'did I call
it decodehdr
or decodehdrs
or decode-hdr
?'. Provided that I
can remember the start of the command, and I usually can, the shell
will now at least guide me to the rest of it and maybe just fill
it in directly (it depends on whether the starting bit uniquely
identifies the command).
One of the interesting consequences of this is that I suspect I'm
going to wind up changing how I name my own little scripts. I used
to prioritize short names, because I had to type the whole thing
and I don't like typing long names. But with command completion,
it's probably better to prioritize a memorable, unique prefix that's
not too long and then a tail that makes the command's purpose
obvious. Calling something dch
might have previously been a good
name (although not for something I used infrequently), but now I
suspect that names like 'decode-mail-header
' are going to be more
appealing.
(I'll have to see, and the experiment is a little bit precarious anyways so it may not last forever. But I'll be sad to be without command completion if it goes.)
|
|