bash command completion for rake

Posted by Tim Connor Wed, 10 Oct 2007 03:29:00 GMT

I’ve written about improved bash completion in OS X before, but when setting up a iMac at my new job (more on that later), I couldn’t recall what I did for tab completion of rake tasks (which is really nice to have if you do much rails work). This time around, I just dropped Lee Marlow’s Rake Command Completion Using Rake into a scripts folder in my home directory, named it rake-completion.rb, and added

complete -C /Users/timconnor/scripts/rake-completion.rb -o default rake

into my .profile (or .bashrc or .bash_login, etc).

If you use one of the ruby completion scripts (like Lee’s) make sure not to drop it in your bash_completion auto-added folder (/opt/local/etc/bash_completion.d/) as that will choke, expecting a bash script, instead of a ruby one.

Running Internet Explorer on Mac through Wine

Posted by Tim Connor Sun, 15 Apr 2007 18:53:00 GMT

While Parallels is awesome and all, for web developers, I got tired of having to run a whole VM at all times for testing. I decided to see if I could get IE running through WIne, and just use my Parallels install for a final browser test. I basically followed these directions. with a couple additions:

  • X11 wasn’t running my .bash_login, so I moved the entire file to .bashrc, and then made a new one that sourced (“source ~/.bashrc”) so that both the OS X terminal and X1 got all my bash set-up stuff.
  • I added “export DISPLAY=localhost:0.0” to my new .bashrc
  • I copied the contents of my Basecamp/Parallels install font folder to my “.wine/drive_c/windows/fonts/”

So now I can just run IE through X11 for my day to day testing. I didn’t get IE7 running, because the betas of that had some issues on OS X, but when they have it polished I’ll give it another shot.

Safari as my primary browser instead of Firefox 3

Posted by Tim Connor Thu, 05 Apr 2007 17:41:00 GMT

After a little while running OS X, it got harder and harder to bring myself to fire up the ‘fox. Safari looks better on OS X, and just seems to run less bloated. Firefox has enough developer friendly extensions that of course I’ll always have it around for when I hit a DOM/css problem, and it’s useful for triangulating the web standards – if it works in Safari and FireFox, it’s good enough until I get to final browser tweaks and have to fire up Parallels.

There is one reason, everything else aside, that I’d continue to find FF a pain on the Mac, as anything else than a last ditch development tool, though: the stupid legacy choice about which modifier key opens in a new tab. Firefox follows the IE lead about adding http:// and .com if you hit enter in the address field, while holding down the primary modifier (CTRL on PC and Command on Mac), so as to make it easier on ex-IE users. That means you have a different modifier for opening in a tab based on wether you are clicking a link or typing in the address bar. Alt (option on Mac), is the “download this link” modifier when using a mouse, and “open in tab” in the address bar. Even though I use a 3-button mouse it’s still damn annoying to have to remember to use the “download” modifier, if I am using the address or search bar. And I can’t seem to find any way to change it – DAMN annoying (and stupid).

Thus yet another reasons that Safari just makes me happy.

TextMate really is growing on me or how to activate project drawer via keyboard

Posted by Tim Connor Thu, 29 Mar 2007 19:50:00 GMT

TextMate may not be an obtrusive, in-your-face, I’ll do that for you", IDE in the style Visual Studio, but the more I use it the more I like it. I think it fits the Mac better, somehow, both the pretty-side and the *nix roots – it’s like vim or emacs with a pretty gui. I could go on about all it’s little not readily apparent niceties that you discover as you start to use it, and I might over time, but first….

After getting QuickSilver set-up I’v been trying to rely on my mouse less. After a bit of that I was still constantly using the mouse for one particular task in TextMate, which lead me to a question: how to activate project drawer via keyboard?

CTRL-TAB will switch you back and forth between the drawer and the editor. Combine that with option-command(aka open apple)-[right|left] arrow for tab switching and you hardly need your mouse.

Superior bash tab completion in OS X

Posted by Tim Connor Fri, 23 Mar 2007 03:47:00 GMT

As a precursor to my upcoming subversion URL completion (I’m still working on the patch), I’m posting about the really cool prerequisite, bash_completion. This is improved, over what is included by default in OS X, extensible tab completion. It does things like limiting options based on the cmd (only listing directories for the “cd” command") and hostname completion for ssh. It also allows for customizable completion for any command, which is the basis of the forthcoming URL completion.

Since it’s not included in the base OS X install, you need to install it yourself. You could go about this a variety of ways, but I went the DarwinPorts route. After installing Xcode, and DarwinPorts, and then using that to install bash_completion (all actually pretty easy), I sourced the file in my .bash_login

source  /opt/local/etc/bash_completion

I’d recommend dropping the most up to date subversion bash_completion script into the bash_completion.d and it will overwrite the default behavior.

Installing mod_proxy on a Mac OS X - Tiger 10.4.8 1

Posted by Tim Connor Tue, 13 Mar 2007 08:13:00 GMT

I’m using Locomotive for my easy Rails install/set-up on my new iMac and been relatively unbothered by not having to download, build, configure, and manage a herd of tools. I installed MySQL, rather than be restricted to the included SQLLite3, but that is simple with the nice installers available from the MySQL AB. Now, I’ve come across the first more complicated “upgrade.”

With the default Locomotive (mongrel) set-up you end up with paths like localhost:3000. This is fine when you only ever have one site running, but causes a problem wih conflicted sessions when you have one site at :3000 and another at :3001. Now many of you are probably familiar with the idea of using Apache as a virtual hosting front-end/proxy. If you do so, and edit your hosts file (or take a quick trip to the NetInfo Manager in OS X) to map http://your_app to you have a much improved situation.

Unfortunately, most of the instructions involved in setting this configuration up, either explicitely presume an Apache 2 install, or walk you through installing it, and OS X comes with 1.3. In the middle of developing a couple apps you may not wish to take time off to fully configure and mess with a full web server upgrade. It’d be much nicer to just add mod_proxy (the one missing piece), configure your vhosts, and call it good.

Figure out your apache version

shell$ httpd -v
Server version: Apache/1.3.33 (Darwin)
Server built: Aug 19 2006 07:55:18

Grab it from the archive and unzip

shell$ curl -O
shell$ gnutar -xzf apache_1.3.33.tar.gz

Use apxs to build and install mod_proxy

sudo apxs -c -i src/modules/proxy/mod_proxy.c

Configure and you’re off (remember to uncomment the LoadModule and AddLoader)

<VirtualHost *:80>
ServerName your_app
ErrorLog /dev/null
CustomLog /dev/null common
ProxyPass /
ProxyPassReverse /

Parallels and Bootcamp - Take 2

Posted by Tim Connor Mon, 05 Mar 2007 20:13:00 GMT

So after getting my iMac back I, of course, wanted to give it another try. This time I did the bootcamp thing first, in case there were any problems. It went smoothly this time – with a new full price retail box of XP Pro.

I partitioned the drive with the Bootcamp assistant, and noticed that it seemed the Apple Store ripped me off, as the drive only indicated 200 gigs on a “250” gig drive (which is actually 230, of course, depending which way you count gigs – it’d be nice if Apple could be consistent between what their software displays, and what the specs/marketing say, of course). Once I got into the Window installer, though, there was a 200 gig untouched partition in addition to the Windows partition. So the 200 gigs was the Mac partition, and there was probably already a Windows partition. It seems to me this means that either they just reinstalled OS X, gave me a $0 warranty receipt, and kept the drive, or Apple actually pre-tested the drive to work with Bootcamp. I’m leaning towards choice number one – but no skin off my nose.

Windows installed as normal – boy it is weird to boot an iMac into Windows. I installed the Bootcamp drivers, but tried not to update Windows any more, so I’d have a base system. The auto-update went through, despite my unchecking it, but fortunately it didn’t seem to update IE any further, which was my main concern (since I am doing this mostly to have IE to test pages with).

Booted back into OS X, and downloaded the newest beta (Release Candidate 3) of Parallels. Installed that, told it to make a VM using the Bootcamp partition, and wallah, we were (basically) done. They even have seemed to fixed the windows reactivation problems, probably with hardware profiles. I didn’t even have to activate Windows again the first time I booted it virtually into Parallels (the docs said you might have to once).

So that I could update this copy of Windows fully, without losing my base IE, I made a fully virtual copy for another VM. Parallels Desktop ships with an additional product Transporter, that lets you migrate a non-virtual install, such as the Bootcamp one to a virtual hard-drive copy. And since my main VM ran off of the hard-drive, it is essentially a “real” install, that just happens to be run through some additional software.

To cut to the chase, I installed the Transporter Agent on the harddrive Parallels VM, and started up Transporter. After a while it was done, and I had an additional VM to play with. Of course, this version does run afoul of activation issues, but I am sure that some people out there could find ways around the activation problems on the additional virtual copies, such as re-keying those copies, or something, if they cared to.

Bootcamp related Mac white screen of death 43

Posted by Tim Connor Sun, 04 Mar 2007 01:13:00 GMT

DO NOT attempt to install a pre-SP2 version of Windows XP on your Bootcamp partition. I don’t know if this happens to everyone, but I definitely found a number of forum and blog posts about it. It may be coincidence and actually be due to a hardware failing, as Apple claims, but it seems like a lethal software bug from my experience and reason.

I don’t even know how this could actually be true, because I didn’t know that SP2 messed with the installer that much, but some some of our experiences validate the theory. The trail to the bug starts when one boots into the Windows install sequence, and it won’t detect the partitions right. Instead of seeing the main partition and a (in my case) 32 GB partition the Windows installer claims there is one 132 GB (or so). Not wanting to mess up their entire computer, most people take the logical step of backing out of the Windows install and rebooting.

At that point I was greeted with a lit but blank screen. Not even the apple logo. Just white nothingness. I rebooted a million times, with different install disks in and different command sequences held down. I cleared the PRAM. I did everything that support would later ask me to do, to no avail. If you hold down the Alt/Option key to get the boot menu, you get the slightly off-white sceen, with no choices on it, just blank. If you hold down ‘x’ to force a boot into OS X, you get a black screen. Nothing works – call support and then they’ll tell you to take your computer in for service.

It seems to me, and others in my camp that Bootcamp is messing with the boot loader to tell it to boot into Windows for the install, and when you back out, due to the non SP2 misreading the partitions (this isn’t a bug exactly, since the requirements tell you to use SP2 or later), it refuses to boot into anything else. Since you didn’t install Windows, though, it can’t boot into that.

Now it’s possible this theory is entirely wrong. Maybe it is actually a hardware problem that prevents the drive from being partitioned correctly, and the Windows install disk was reading it correctly. That, of course, wouldn’t explain why it wouldn’t run the install from the external drive they tried at the Apple Store.

Of course, I could test this by attempting to install from the same Windows disk when I get my computer back, but I think I’ll play it safe and not. And before anyone suggests Paralells, I already have it. I wanted to use the new feature where you can run the VM from the Bootcamp partition, so you only have to maintain one main install, both for running natively through Bootcamp for performance reasons (like if you want to game), or virtually with Paralells.