Fundamentals 6 min read

Boost Your Terminal Navigation: Master zoxide for Smarter cd Commands

This guide introduces zoxide, a smarter replacement for the cd command that learns your most‑used directories, explains its key features, shows how to install it via curl or cargo, and provides configuration tips and usage examples for faster command‑line navigation.

Efficient Ops
Efficient Ops
Efficient Ops
Boost Your Terminal Navigation: Master zoxide for Smarter cd Commands

What is zoxide?

zoxide is an intelligent replacement for the cd command, inspired by z and autojump. It remembers the directories you visit most often, allowing you to jump to a target path by typing just a few characters. It works with most major shells.

zoxide diagram
zoxide diagram

Key Features

Interactive search : use the zi command to invoke fzf for visual directory selection.

Replace : the --cmd cd option can override the built‑in cd command.

API extensions : provides low‑level functions such as __zoxide_z for developers.

Basic Usage

z foo      # jump to the most frequently visited directory matching "foo"
z foo bar  # jump to the most frequent directory matching both "foo" and "bar"
z foo/    # jump to a subdirectory starting with "foo"
z ~/foo   # use z as a regular cd command
z ..      # go up one level
z -       # return to the previous directory

Installation

zoxide can be installed on Linux/WSL, macOS, Windows, BSD, Android, etc.

Via script:

curl -sSfL https://raw.githubusercontent.com/ajeetdsouza/zoxide/main/install.sh | sh

Via Cargo (cross‑platform):

cargo install zoxide

Shell Configuration

Add the following line to the end of your shell’s configuration file (e.g., ~/.bashrc).

eval "$(zoxide init bash)"

Optional fzf Installation

fzf provides fuzzy finding for interactive selection. Example for Ubuntu:

sudo apt install fzf
source <(fzf --zsh)

Note: the minimum supported fzf version is v0.51.0.

Configuration Options

--cmd <PREFIX>

: change the prefix of the z and zi commands. --cmd j: use j and ji as the command names. --cmd cd: replace the original cd command. --hook <HOOK>: set how zoxide updates directory‑usage frequencies.

Environment Variables

_ZO_DATA_DIR

: specify the directory where zoxide stores its database.

Default locations vary by OS (e.g., $XDG_DATA_HOME or $HOME/.local/share on Linux/BSD, $HOME/Library/Application Support on macOS).

Summary

zoxide combines directory‑frequency, recent‑access time, and path matching for precise jumps. Compared with z, it offers interactive search and customizable commands while still supporting simple frequency‑based jumps. Use z -l or zq to view full directory history.

productivityshellCommand Linecd alternativezoxide
Efficient Ops
Written by

Efficient Ops

This public account is maintained by Xiaotianguo and friends, regularly publishing widely-read original technical articles. We focus on operations transformation and accompany you throughout your operations career, growing together happily.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.