Chris Lamb

Optimising directory navigation with multiple terminals

This simple shell snippet has saved me countless keystrokes and mental context switches. It works on the assumption that most tasks are based in or around a single directory such as a Git working tree.

s() {
        pwd > ~/.saved_dir

i() {
        cd "$(cat ~/.saved_dir)"

I typically use it like this:

$ cd /srv/long/path/that/is/tricky/to/autocomplete
$ ls
one   two   three
$ s

(Switch to another terminal tab or GNU Screen window, etc.)

$ pwd
$ i
$ pwd
$ ls
one   two   three

This saves me having to navigate—or even think about navigating—to the deeply nested directory.

Chris Lamb is a freelance software developer and the current Debian Project Leader. You can read other posts by me, see software I have written or read more about me. You can also follow me @lolamby.

Tags: Hacks GNU/Linux

Planets: WUGLUG UWCS Debian ALUG

Saturday 30th July 2011

Nine comments