Thursday, July 10, 2008


I'm a fan of aliases and basically anything else that can help me type less when doing stuff on the command line. My home directory often has a number of symbolic links to various projects and libraries, and 'til now I've gotten by with this amalgamation of tools and techniques just fine.

Still, I'm always looking out for new tips and tricks, and one of the best and easiest ways to pick up some invaluable knowledge from others is to see how they use their shell. I forget sometimes that some of the shortcuts I know and love aren't used by others; I've had people say "wait, what was that?" when I do

$ mkdir something_here
$ cd !$

or even a simple !!, !mer, ctrl+r rake, etc. Still, you can only know so much, and recently I was that person saying "waaaiiit a sec..." while watching wycats fly around various directories with this little command 'cv'.

Enter cdargs

Take a look at its homepage here and come back when done scanning.

If you follow the instructions you'll have a nice and small 'cv' command at your disposal. Now, maybe it was related to the fact that I was doing this at 3am, but I definitely didn't get it at first, and its actually quite simple.

In browse mode you can easily traverse your file system and type 'a' along the way to add directories to your list. This means that you can just type 'cv' from anywhere, easily select something from your list, and change to it quickly. Nice, but still a little verbose for my liking. However, you can also use a name from your list and cv to it directly, which is just damn cool.

So, an example. My current list looks something like this:

0 [merb ] /Users/jackdempsey/git/merb
1 [thor ] /Users/jackdempsey/git/thor
2 [dm ] /Users/jackdempsey/git/dm
3 [git ] /Users/jackdempsey/git
4 [recollectr] !/Users/jackdempsey/recollectr
6 [testbed ] /Users/jackdempsey/testbed

Which means from any location i can type 'cv git' or 'cv merb' etc and jump to the directory directly. So much nicer than the 'cd ~/symbolic_link_here' that I've gotten used to.

So try it out. I think its one of those things that as soon as you build up the muscle memory for it, you'll never want to go back. Much thanks to Yehuda for showing me the light on this one.


Anonymous said...

zomfg! thanks a lot for making me discovering this awesome life-changing tool!

Jack Dempsey said...


glad you like it. makes things much easier huh!

David said...


you may also want to look at the CDPATH variable. It works for directories in the same way that PATH works for commands. So, for example, if you have /usr/local in your CDPATH you can do

$ pwd
$ cd lib
$ pwd

Jack Dempsey said...


Very cool, I've heard people mention CDPATH before, but never used it myself. Thanks!

Chris Lloyd said...

I made something like this (although not as flexible) for switching between projects. You can see it in Xavier Shay's dotfiles. Autocompletion makes it very quick alternative.

Jack Dempsey said...


Cool. I find complete to be incredible helpful when you need it.

A follow up to the CDPATH comment: I swear I just had a problem installing erlang because of it. It kept failing with a "no dir: cd erts/something" when the directory was definitely there. When I started a new shell without setting CDPATH, it worked fine. Maybe I set it wrong somehow...but buyer, be aware...