DEV Community

satoru
satoru

Posted on

Faster Way to Change Directory on Linux/macOS

As developers, we spend a lot of time working in the command line, and we change directories frequently. Procedures that we do frequently are worth optimizing, in this post I'll introduce a tool I wrote that might help you save more time changing directories.

Suppose that in your daily development routine, you often need to switch between the following directories:

cd ~/go/src/github.com/pingcap/tidb
cd ~/go/src/github.com/pingcap/tidb-binlog
cd ~/projects/redis
cd /tmp
cd /usr/local/Cellar
Enter fullscreen mode Exit fullscreen mode

Without any tool, the best you could do to save some typing is to use .. or shell history. But we can do better.

I rewrote autojump in Go and created the tool shonenjump. With this tools, once you have entered the previous directories once, they would be saved in a data file, and then we can access them quickly:

j tidb # Jump to ~/go/src/github.com/pingcap/tidb
j go git tidb # Jump to ~/go/src/github.com/pingcap/tidb
j tm # Jump to /tmp
j Cell # Jump to /usr/local/Cellar
Enter fullscreen mode Exit fullscreen mode

If you are interested to improve your productivity, please give it a try, it can be easily installed and uninstalled with Homebrew on macOS.

Top comments (2)

Collapse
 
jonrandy profile image
Jon Randy πŸŽ–οΈ

This seems pretty much identical to "z", which is awesome - github.com/rupa/z

Collapse
 
satoru profile image
satoru

It's a rewrite of autojump (or "j") which supports fuzzy matching.