Entries for label: bash-completion

Found 1 entry.

Cil now has Bash Completion

Another day, another feature added to cil. It's rocketing along.

I've never written anything for bash completion before (someone else has always done it for me) but I had a go at it tonight. After an hour and 15 I had it working quite well.

I was suitably impressed with the whole thing since even though I knew doing it for commands and/or options would be easy enough, I managed to do it for a few other things too (more later).

For example:

 $ cil a<tab><tab>
 add attach
 
 $ cil s<tab><tab>
 show status summary
 
 $ cil --<tab><tab>
 --filename --help --label --path --status --version

That's all happy and nice but the following feature is the killer and will make working with issues a breeze. It also completes the actual issue/comment/attachment name, giving you the choice of the correct type where necessary.

Let's say your issues/ dir contains three issues, two comments and one attachment:

 $ ls -1 issues/*.cil
 issues/a_85eceee9.cil
 issues/c_d8dd779f.cil
 issues/c_feb65ae7.cil
 issues/i_02ee35bd.cil
 issues/i_5c88cb30.cil
 issues/i_98203ce8.cil

When doing the following, it completes to one of the three issue names:

 $ cil show <tab><tab>
 02ee35bd 5c88cb30 98203ce8

as it also does for the other commands that act on issues (status, edit, comment and attach).

Another example would be for extracting attachments:

 $ cil extract <tab><tab>

completes to:

 $ cil extract 85eceee9

This is pretty good stuff already but I can already see that it can be used a lot more in the future...

Let's say you allow the following statusus in your issues: New, InProgress, Finished and WontFix. Then, setting the status of an issue would work like:

 $ cil status 02ee35bd <tab><tab>
 InProgress Finished New WontFix

Really straightforward and really fast, which are basically two of the things I wanted cil to be from the start - I just didn't realise it would be so easy :-)

Seeing as I try and credit people where I can, thanks to Francois for the suggestion of adding bash completion. It's given me a chance to learn something new to me but very powerful.

Note: this feature is in Git and will be in the v0.3.0 release.

Labels: cil, bash-completion, planet-catalyst

Inserted: 2008-06-24 23:44 (3 years, 7 months ago)