2008/04/23
I was tired of the command line traversing though my somehow dispersed directory hierarchy.
The reason is that I have basically 3 separate locations where I need the Terminal frequently: a subversion tree for writing, a subversion tree for my code and another code CVS repository. These are three directories I typically cd into.
With Terminal you can set the initial directory. For me this is the Inbox. This doesn’t help though with getting around fast. One quick solution to do this is use the environment variable CDPATH. Including the three paths above to the CDPATH allows for direct cd-ing into the sub-directories. But there’s a problem:
Tab completion does not work with CDPATH. Solution? Extended bash completion. You can get bash-completion via maports. (Don’t forget to include it in your .bashrc: source /opt/local/etc/bash_completion)
Another thing that is quite nice is the Quicksilver (QS) Terminal module plugin. With this you can browse through using QS and then select “Go To Directory in Terminal” as the action. I use this one typically, when creating a new shell. However, when I’m already in a Terminal I don’t like to switch contexts and rather use the Terminal itself.
I’m still looking for something like a stack of recent paths cd’ed into to quickly change directories via some shortcut.
UPDATE: I really dig bash completion: If you have a directory with many folders just distinguished by an integer-suffix, a ‘cd’ without specifying the integer results in cd’ing into the one with the largest number.
Why is this useful? I have a folder with lots of exercises for a class. I add a folder per exercise, but typically am only interested in the most recent one, i.e. the one with the largest suffix. Nowadays, I do not need to specify the number of the latest exercise anymore. I rather enter
cd exercise
and change into directory exercise8 (as it is the 8th this week) automagically.
Leave a Reply
You must be logged in to post a comment.