Tom Morris

15 July 2007

A pungent mix of programming, philosophy, pedanticism, procrastination, perplexity, peripheral political polemic, and platters of preposterousness.

Using oxygen from the command line

I spend a lot of time at the command line, and I always end up doing stupid things like trying to edit XML files in SubEthaEdit or, worse, nano. It’s stupid, because I’ve got this gigantic, fully-featured XML editor on my desktop. But because it’s less mental effort to type “see foo.xml” than to go to my Dock, click Oxygen and then navigate the OS X tree to find it, I never bother.

Today I thought I may as well set up bash to let me edit stuff in Oxygen. On the Mac, Oxygen has a shell script - ‘oxygenMac.sh’ - but it does some silly crap with the current working directory.

I’ve written a script called oxygen.py which you should be able to use. To install it, put it in ~/bin or wherever else you run your scripts from.

I’ve edited my .bash_profile to add an alias:

alias oxygen="python /Users/tom/code/oxygen.py "

You can use this from the command line in two ways:

oxygen [filename]

or by piping in data as STDIN

If you specify a filename, Oxygen will open that file. If you do not specify a filename, STDIN will be read in to a temporary file, and that will be opened in Oxygen.

Total programming time? Half an hour or so. Amount of time saved? Quite a lot, hopefully.

Tags: , ,

|

Tags:

Being able to trigger things in the future using QuickSilver is very useful. Who needs to bother with those shareware iTunes alarms? Just point QuickSilver to a playlist and tell it to run it at a certain time. The power of this little piece of software really is mind-blowing sometimes.

Tags: