% pwd
/home/aram
% cd mstate
/home/aram/src/launchpad.net/juju-core/mstate
% cd go/src
/home/aram/go/src
% cd plan9
/home/aram/plan9
%
It uses the $CDPATH environment variable ($cdpath in rc(1)). $CDPATH is a list of places in which to search for the wanted directory. I put all the things I regularly use there, and my cds are almost always short, usually just a single name.
I don't maintain $CDPATH myself, my profile runs a one liner that descends into certain directories and constructs $CDPATH for me within the constrains of some rules (for example excludes leafs, excludes {bin,doc,pkg,test}, etc).
Finding about $CDPATH was a huge productivity boost to me, not only in time saved typing, but in allowing me to change the way I work. I now rarely care where things in the filesystem are (e.g. various source code for various software, where the build products are, etc). I used to do a lot of moving and symlinking around, to arrange stuff so I remember where I've put it and to keep paths short, but now I don't care. It could be wherever, it's just one name away. The namespace had become a big hash.
This is a pretty good solution, however there are a few things other programs add on:
- $CDPATH requires manual management. You're using a line in profile, but I imagine that's limited to specific directories and creates overhead when creating new shells.
- What happens with namespace collision? First entry in $CDPATH wins?
- Fuzzy searching for mistyped directory names. I don't find this feature that useful personally, but was requested quite a bit by others.
Rc(1) is the Unix v10/Plan 9 shell[1] written by Tom Duff[2], of Duff's device[3] fame. Rc(1) is of course available in Unix as well, I use the port from plan9port[4].
'The search path for the cd command. This is a colon-separated list of directories in which the shell looks for destination directories specified by the cd command. A sample value is ".:~:/usr".'
In case anyone else is wondering what "frecency" is:
Frecency is a portmantaeu of ’recent’ and ’frequency’. It is a weighted rank that depends on how often and how recently something occured. As far as I know, Mozilla came up with the term.