Scrawls from Preston...

Powered by Pelican.

Fri 12 March 2010

Bash completion for diskutil (and others...)

A few of the tools I use have spent some time working up bash completing. django-admin and virtualenvwrapper to name two. As a Mac sysadmin I use a number of CLI tools for stuff, and was interested in working up some bash completion for these.

I picked diskutil for starters as its one I use with some regularity on my personal machine (mainly for force unmounting stubborn volumes) as well it has a pretty basic verb set. Other candidates to apply this two would be hdiutil, severadmin, dscl - I'm sure there are a bunch. It would be interesting to work these up into a single package someday if the effort can ever be marshalled.

I borrowed the approach used in Django of having the completion choices be determined by a python script as it is much more pleasant (for me) to put together any logic or algorithms in Python vs Bash. The same approach could be used with Ruby, Perl, etc.

You can find the project [here](http://bitbucket.org/ptone/diskutil_completion/)

Click below to watch a micro screencast:

image0


http://ptone.com/dablog