Moving between directories
- 0
- Add a Comment
Moving Between Directories
We’ve talked quite a bit about bash, the Bourne Again Shell in Linux.
It’s the most popular shell environment and contains, arguably, the most and
most useful features. Among them are command line completion, wild card use and
many, many others.
If you’re working a lot in the terminal, you know that, even in bash, entering
directory paths can be a bit of a pain. Even with command line completion (using
the tab key to complete the command line) moving between directories is a bit
more complicated than many would like. Today’s TWEAK is, in fact, a built in
function of bash that will allow you to move between the current and previous
directory even more quickly than you can with command line completion.
Let’s say I’m moving between the following directories:
/home/tony/bin
/usr/local/src
When in the first directory, I could easily enter:
cd /u[tab]/lo[tab]/sr[tab]
to move to the second directory. Count ‘em. That’s 13 keystrokes (including the
[enter] key) to change directories - exactly 8 more than the following
command:
cd -
The [-] symbol, when used after the cd command, returns you to the previous
directory. You can jump back and forth between directories with much less finger
stress.
Enough of these little tweaks and we could make a significant dent in carpal
tunnel syndrome, don’t you think?
