Tab completion and ssh/open -a

I use the Terminal just as much as the Finder, and have tab-completion turned on in bash. To make it better, you can set it so that it will complete differently depending upon what you have already typed in.

The first one of these tips will autocomplete from the ~/.ssh/known_hosts file, so that when you type in:

$ ssh ma[tab]

1
complete -W "$(echo `cat ~/.ssh/known_hosts | cut -f 1 -d ' ' | sed -e s/,.*//g | uniq | grep -v "\["`;)" ssh

it will autocomplete the servers you ssh to that start with “ma”.

The next one is more complicated - it allows you to complete from all available applications when typing:

$ open -a [tab]

1
complete -W "$(/bin/lsregister -dump | /usr/bin/sed -E -n -e '/\/Applications/{s/^.+ ((\/Applications|\/Developer).+\.app)$/\1/p;}' | \/usr/bin/sed 's/ /\\ /g' | \/usr/bin/sed -e s/\'/\\\\\'/g | /usr/bin/xargs /usr/bin/basename -s '.app' | /usr/bin/sed 's/ /\\\\\\ /g')" open -a

These can be added to one of your bash startup files: mine live in ~/.bashrc.

What's Open Flaws

First thing I did when looking at a new site: What’sOpen.com.au (although, I think the apostrophe isn’t there in the domain name!), search for some results.

Geez, I’d be pissed if I were the first hit in the list.

whatsopen.png

It’s a bit scaled, but on Safari, the first item is almost totally obscured by the header graphic.

Oops.

Pragmatic Programmers website is broken.

WillFuckingShipley.png

Food Chain

foodchain.jpg

via Don’t Eat My Brain.

Evil Xmas

evilXmas.png

Finished evil xmas shopping. Bought junk that’s the wrong size & color for everyone so waiting in line to exchange is guaranteed.

Battery...

Dear Apple,

Please send me the battery that you said you would. I’m not really liking when I see this:

battery.png

That’s not much fun at all.

Regards,

Matt.

Bleed The World

This video is totally worth it too. Follow the link to see this one.

At Christmas time we should always spare a thought for those less fortunate than us. After 20 years of bleeding the world, the global financial community has fallen on hard times. These people desperately need our thoughts, prayers and lots of our money. If you have any investments or savings left, or any money left over at the end of the month please, please give generously. Merry Christmas.

From Bleed The World

YouTube - Fainting Goats

Thanks to the Macalope, I came across this video on youtube:

Fainting Goats: From YouTube - Fainting Goats

Mac OS X Internals: A Note on Automounting MacFUSE File Systems

A Note on Automounting MacFUSE File Systems

Mac OS X, like many other Unix-like operating systems, includes the “autofs” file system layer that make automatic on-demand mounting of remote resources possible. See the man page for automount(8) for more details.

From Mac OS X Internals: The Blog » Blog Archive » A Note on Automounting MacFUSE File Systems

Awesome. This might replace the need for ExpanDrive. And be even more automatic.

Sometimes, the bugs aren't mine...

I’ve just spent about five hours working out some kinks with data migration between an SQLite database, and a PostgreSQL database. I’m using SQLAlchemy as the transfer tool, since the newer PGSQL database is created and only ever used through this interface.

The big issue I’ve hit is with some Numeric types. One table has Numeric values, which are NULLABLE, but for some reason when I try to load objects from this table, decimal.Decimal throws an exception.

But here is the weird bit. If I rerun the query, and try to load the same object a second time, it succeeds.

Since I needed to access all of the rows from this table, I had to keep trying to load them until I’m no longer throwing exceptions, and then finish. I had a nice code sample from SubEthaEdit, but that seems to have a bit of a bug with the Copy As XHTML feature in the newest build (submitting a bug report now).