Command-line utilities to replace “
cd” command for faster file system navigation.
In some of my previous articles, I walked through with you tools that could improve your development workflow. One of the command-line utilities is
autojump which is a faster way to navigate the filesystem.
For developers, we mostly live within the terminal. Having a faster way to navigate the filesystem can definitely improve our productivity. In this article let’s explore the possible options we have.
Jumping Between Directories
Let’s start with some of the built-in commands.
alias: You can easily create
aliasfor the most commonly used directories, e.g. your project folder
$ alias p="cd $HOME/projects"
- Reverse/forward search: You can do a reverse search (
Control-R), or forward search (
Control-S) for the command history.
cd-: Use “
cd-” to go back to the previous directory. You can also add a number to indicate how many folders you want to go back to, e.g. “
pushdto save the current directory to the top of the directory stack and change the current directory to the folder.
dirsto display the directory stack.
popdto remove the top directory from the stack and navigates to the new top directory.
There are possibly more options than I listed above.
autojump is definitely one of the most popular options.
autojump works by maintaining a database of the directories you use the most from the command line. Directories must be visited first before they can be jumped to.
j foo: Jump to a directory containing foo.
jc bar: Jump to a child directory.