2006-04-10

You complete me

Being the lazy typist, like most programmers, I use command/file-name completion A LOT. I probably press "tab" more than I do "return". That works fine for the commands and for the file arguments.
However, there are a few command-line programs that are collected into toolkit style and operate on the form:

command subcommand subargs

It's sometimes a useful thing to do to wrap a bunch of little but related commands into a single command line, especially when the subcommands would otherwise share a bunch of code and procedures. Sadly, completion doesn't fill in choices for the secondary command; how can it? So one has to remember what choices there are and type the whole thing. This also applies to commands where the argument is another command, string, or filename that may not exist yet, as in makefiles.

But no more! Found another little *nix gem that's been in existence for who knows how long but lost on me because I never bothered reading the complete bash man page. I was alerted to it during my dig on Ruby Rake tips. Basically it concerns being able to write your own bash completion. Way cool!

In the makefile (and rakefile) example, it's very convenient to type "make [tab]" and get a list of possible targets of make. And in my toolkit example, I can type "command [tab]" and get a list of possible subcommands and a completion when it's unique. Very handy. It can save seconds at a time and has some good "wow" potential since I haven't seen anyone else in my group use this feature. I don't feel so bad that I missed this little time-saving gem all these years, but I wish I had known of it earlier.

1 comment:

Anonymous said...

o....m....g....

hopeless....

simply hopeless...