Aliases to the latest branch folder you’re working on
For my Rails and RubyGem projects I’ll run multiple branches plus a trunk. The trunk represents the live, public/production code, and the branches represent new features being developed [1]. So if I’m working on a branch for a feature, and I open a new terminal shell, THAT’s the working folder I want to go to, not the trunk, nor any other branch. Just that one.
Even for small gems and projects where I have no branches, just a trunk, I want quick ways to get to the working folder. [2] You know, the branch I was just working on two seconds ago.
So, if I have a project (rails app or gem) called wizzo, and I’ve checked out the trunk and some branches into a common folder:
- /path/to/wizzo —trunk
- /path/to/wizzo_feature1 —branch for feature1 (Last touched)
- /path/to/wizzo_feature2 —branch for feature2
OR, if I checkout the trunk and all branches into one folder:
- /path/to/wizzo/trunk —trunk
- /path/to/wizzo/branches/feature1 —branch for feature1 (Last touched)
- /path/to/wizzo/branches/feature2 —branch for feature2
I want an alias wizzo to take me to /path/to/wizzo/branches/feature1 if that is where I’m working at the moemnt.
If you want this too, do the following:
$ sudo gem install latest_branch
And for each folder that contains your projects, add the following to your .profile:
alias_all_projects –path=~/Documents/rails_apps/
. ~/.project_aliases
And this will generate many wonderful, dynamic aliases for you.
See the latest_branch website for the ins-and-outs, and its helper app latest_branch.
[1] At work - a non-ruby/rails, billing system on CVS - we do it differently. The trunk is for development of all new features, and production releases are tagged, and also branched for critical fixes. But the above code would be useful for both situations.
[2] Lucky zsh shell users can do fancy stuff like map folders to ~proj folders, and use autocomplete, such that cd ~p/t might go to ../proj/trunk. Neat.
Trackbacks
Use this link to trackback from your own site.

BTW - it uses the location of
Rakefileto determine the root folder of projects (ignoring paths with pkg/vendor/template in it).If you want to use this for non-Ruby project folders let me know and I could add a switch to look for alternate root files.
Perhaps README is a better root file to look for.
Also, its likely that this script will generate some crap aliases, but hopefully they are irrelevant and don’t affect your auto-completion for other things.
For this type of magic directories, I love WD. It’s a small set of scripts and aliases for doing pretty much what you describe here.
http://freshmeat.net/projects/wd/
I never build a new dev machine w/o it.