Command-line shortcuts

I came across an interesting little program the other day. It's called Go. It's a Python script for quickly navigating directories via what are essentially command-line shortcuts. I discovered it while perusing the settings in my Komodo Edit preferences - it was mentioned in the settings for the Fast Open extension, which I believe is included by default as of Komodo 5.1.
komodo-fast-open.png
The beautiful thing about Go is how simple it is. You run a simple command to set an alias and from there on out, you can just type go alias and it will change you to that directory. You can also add paths after the alias, such as go alias/dir1/dir2 to switch to a subdirectory of the alias. Great for switching between deep hierarchies, like how Windows programs like to bury things three levels under your "Documents" directory.

However, as I played around with Go, I did come across a few annoyances. The biggest one, or course, was that it didn't work under Powershell. The go.bat wrapper script would run...and do nothing. The current directory stayed the same. Turns out this was because go uses a driver-based system for changing directory which is based on your current shell. The Windows driver was using batch file syntax and running cmd.exe. Powershell does this in a new process, so naturally the current directory wasn't changing.

So, in the spirit of open-source, I decided to fix that problem. And while I was at it, I fixed a couple of other things and implemented some of the feature requests posted on the Google Code issue tracker. Here's the quick list:

  • Added support for Powershell.
  • Added built-in shortcut "-" pointing to the OLDPWD environment variable. On Windows, Go handles setting this variable (on UNIX, "cd" takes care of that).
  • When invoked without any argument, change to home directory.
  • Resolve unique prefixes of shortcut, e.g "pr" resolves to "projects" if there's no other shortcut starting with "pr".
  • Made -o option work without having the win32api bindings installed.

Below are a patch file for the official Go 1.2.1 release (apply with patch -p2 < go-posh.patch) as well as a fully patched setup archive for those who just want to get up and running. Note that, to enable Powershell support, prior to running the Go setup, you'll need to set the SHELL environment variable so that Go knows to use Powershell. You can do this by adding $env:SHELL = "powershell" to your Powershell profile script.

Patch file: go-posh-1.2.1.patch
Full Go archive: go-posh-1.2.1.zip

Edit: Fixed support for "-" so that it actually works like it does in UNIX.

Edit again: I've added a few more small features and also created a project for this patch in my bug tracker.

New year's link clearance

In the spirit of Raymond Chen, it's time for new year's link clearance! In other words, I'm posting all those links that have been sitting open in my Opera window for weeks which I'm probably never going to actually do anything with.

  • A post with some code for doing prototype-based inheritance in PHP. As in, writing your PHP like it's JavaScript. Yeah, cause good things always come from trying to openly defy the conventions of your langage of choice.
  • MVC is a lie. Good, at least I'm not the only one who finds some of these "MVC" frameworks a little questionable, with their grossly anemic domain models. Although I guess I have to give the CakePHP people credit on that one. They're at least in touch with reality. What with passing around of arrays of database records, they don't even pretend they're working with real model objects.
  • A helpful link from F5 about parameters for Powershell scripts and some other useful stuff.
  • Request/response testing in Powershell using the handy, dandy .NET WebClient class.
  • A Get-ScriptDirectory function for Powershell. Kind of like PHP's __FILE__ trick.
  • An interesting article on object-oriented event listeners for JavaScript.
  • Wikipedia page on the SEI's Personal Software Process (PSP). I was put onto that by reading Smart Bear's book on code review, which was actually quite interesting. I'd definitely recommend it. It's totally free, but is published in dead-tree format, which is weird, but I haven't gotten any sales calls or anything, so they're cool.