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 http://www.skamphausen.de/cgi-bin/ska/CDargs 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.
6 comments:
zomfg! thanks a lot for making me discovering this awesome life-changing tool!
@sr,
glad you like it. makes things much easier huh!
Jack,
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
/home/david
$ cd lib
$ pwd
/usr/local/lib
David,
Very cool, I've heard people mention CDPATH before, but never used it myself. Thanks!
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.
@chris,
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...
Post a Comment