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.
jo music: Open file manager to a directory (instead of jumping).
jco images: Open file manager to a child directory.
autojump is available for Linux, macOS, and Windows.
z, zsh-z, and z.lua
z (jump around) is available for
zsh. It tracks your most used directories, based on ‘frecency’. After a short learning phase,
z will take you to the most ‘
frecent’ directory that matches all of the regexes given on the command line, in order.
zsh-z is a native
zsh port of
z foo bar would match
/foo/bar but not
Frecency is a portmanteau of 'recent' and 'frequency'. It is a weighted rank that depends on how often and how recently something occurred
z.lua is an alternative to
z with Windows and POSIX shells support and various improvements. It is also base on frecency just like
z.lua claims to be 10x times faster than
autojump, 3x times faster than
z. It is available for POSIX shells:
busybox, and Fish Shell, Power Shell, and Windows
z foo # cd to most frecent dir matching foo
z foo bar # cd to most frecent dir matching foo and bar
z -r foo # cd to the highest ranked dir matching foo
z -t foo # cd to most recently accessed dir matching foo
z -l foo # list matches instead of cd
z -c foo # restrict matches to subdirs of $PWD
z -e foo # echo the best match, don't cd
z -i foo # cd with interactive selection
z -I foo # cd with interactive selection using fzf
z -b foo # cd to the parent directory starting with foo
Fasd (pronounced similar to “fast”) is a command-line productivity booster.
Fasd offers quick access to files and directories for POSIX shells. It is inspired by tools like
Fasd keeps track of files and directories you have accessed so that you can quickly reference them in the command line.
Fasd comes with some useful aliases by default:
alias a='fasd -a' # any
alias s='fasd -si' # show / search / select
alias d='fasd -d' # directory
alias f='fasd -f' # file
alias sd='fasd -sid' # interactive directory selection
alias sf='fasd -sif' # interactive file selection
alias z='fasd_cd -d' # cd, same functionality as j in autojump
alias zz='fasd_cd -d -i' # cd with interactive selection
zoxide (written in Rust) is a blazing fast replacement for your
cd command, inspired by
z.lua. It keeps track of the directories you use most frequently and uses a ranking algorithm to navigate to the best match.
z foo # cd into highest ranked directory matching foo
z foo bar # cd into highest ranked directory matching foo and barz ~/foo # z also works like a regular cd command
z foo/ # cd into relative path
z .. # cd one level up
z - # cd into previous directoryzi foo # cd with interactive selection (using fzf)
zoxide integrates with
fzf and there is also a plugin available for Vim/Neovim.
Jump integrates with your shell and learns about your navigational habits by keeping track of the directories you visit. It gives you the most visited directory for the shortest search term you type.
autojump, it introduces the j helper which can be bind to another letter.
$ j wc # or...
$ j webc # or...
$ j console # or...
$ j b-c # or...
Terminal File Manager
Let’s explore the options we have for terminal file manager.
ranger is a console file manager with
vi key bindings. This is one of the most popular options.
- UTF-8 Support (if your Python copy supports it)
- Multi-column display
- Preview of the selected file/directory
- Common file operations (create/chmod/copy/delete/…)
- Renaming multiple files at once
- VIM-like console and hotkeys
- Automatically determine file types and run them with correct programs
- Change the directory of your shell after exiting ranger
- Tabs, bookmarks, mouse support.
It is designed to be unobtrusive with smart workflows to match the trains of thought.
nnn can analyze disk usage, batch rename, launch apps, and pick files. The plugin repository has tons of plugins to extend the capabilities further e.g. preview, (un)mount disks, find & list, file/dir diff, upload files.
lf (as in "list files") is a terminal file manager written in Go.
- Cross-platform (Linux, OSX, BSDs, Windows (partial))
- Single binary without any runtime dependencies (except for
- Fast startup and low memory footprint (due to native code and static binaries)
- Server/client architecture to share file selection between multiple instances
- Configuration with shell commands
- Customizable keybindings (vi and
- Preview filtering (for source highlight, archives, pdfs/images as text, etc.)
fff (Fucking Fast File-Manager) is a simple file manager developed in
- It’s fast
- Minimal (only requires
- Smooth Scrolling (using vim keybindings)
- Works on Linux, BSD, macOS, Haiku, etc.
- File Operations (copy, paste, cut, ranger style bulk rename, etc)
- Instant as you type search
- Tab completion for all commands!
- Automatic CD on exit (see setup)
- Works as a file picker in
- Display images with
vifm (vi[m] like file manager) is a curses-based vi[m] like file manager extended with some useful ideas from mutt. If you use vi[m], vifm gives you complete keyboard control over your files without having to learn a new set of commands. It goes not just about vi[m] like keybindings, but also about modes, options, registers, commands, and other things you might already like in vi[m].
GNU Midnight Commander is a visual file manager. It is a feature-rich full-screen text mode application that allows you to copy, move and delete files and whole directory trees, search for files and run commands in the subshell. Internal viewer and editor are included.
Other Options — For Vim/Neovim Users
For Vim/Neovim users, instead of using the above command-line utilities, you can easily switch projects or folders using plugins.
Check out this article to see how to switch between multiple projects and folders easily from within Vim/Neovim.