zoxide — smart cd
💬 "zoxide command"
zoxide is a smart cd that learns your frequently visited directories. Instead of using complex full paths, you can jump directly to any directory with a short pattern.
It scores directories based on visit frequency and recency to select the most suitable path.
- Concept: Accelerates directory navigation based on your visit history.
- z command: Use z instead of cd to navigate using partial patterns.
- Smart Matching: Prioritizes suggesting paths you visit most often.
- Shell Integration: Integrates automatically with bash, zsh, and fish.
Installation and Download
Install zoxide using a package manager or a script.
| Environment | Command | |
|---|---|---|
| Ubuntu / Debian | sudo apt install zoxide | |
| Fedora / RHEL | sudo dnf install zoxide | |
| Arch | sudo pacman -S zoxide | |
| macOS (brew) | brew install zoxide | |
| Script Install | curl -sSfL https://raw.githubusercontent.com/ajeetdsouza/zoxide/main/install.sh | sh |
| Binary Download | github.com/ajeetdsouza/zoxide/releases |
After installation, add eval "$(zoxide init bash)" to your shell configuration to enable the z command.
Frequently Used Options
| Option | Description |
|---|---|
| z <pattern> | Navigate to a directory matching the pattern |
| zi | Select a target directory interactively |
| z -e | Search only directories containing executable files |
| z -x | Remove directories with low visit counts |
| echo $ZOXIDE_SCORE | Check the scoring system |
3 Essential Command Combinations
z www— Navigate to a directory containing the pattern /wwwzi— Select a directory from an interactive listz -x rarely-used— Clean up records of infrequently visited directories
💬 "Show me an example of quickly navigating directories using zoxide on a real server."
Here is a step-by-step walkthrough of common scenarios encountered on a production server.
Step 1 · Installation and Initialization
After installation, integrate it into your shell.
sudo apt install -y zoxide && echo 'eval "$(zoxide init bash)"' >> ~/.bashrc && source ~/.bashrc
Step 2 · Memorize Directories
Visit a few frequently used directories several times.
cd /var/www/html && cd /etc/nginx && cd /home/ubuntu
Step 3 · Quick Navigation
Navigate using just a pattern.
z www
Real Execution Output
The result of navigating to a directory using a short pattern after installing zoxide.
!zoxide command execution result
Production server in operation
Practical Usage Examples
1. Switching Between Projects
Scenario — Navigate between multiple projects using short names.
z sks
Result — Instantly navigates to /home/jw/coding/commands/sks.
Key Point — A single short pattern eliminates the need to memorize the entire path.
2. Cleanup
Scenario — Remove infrequently visited directories from records.
z -x old-project
Result — The specified directory is removed from memory.
Key Point — Keeps memory clean, improving matching accuracy.
Real Execution Output
The result of selecting a directory using interactive selection (zi).
!zoxide command execution result 2
Production server in operation
Important Considerations
- If you do not add zoxide init to your shell configuration, the z command will not be recognized.
- Visit history is accumulated separately for each server. On shared servers, each user's history is different.
- If the match is incorrect, you can select directly from the interactive list using zi.
- It may conflict with existing cd aliases. Check for conflicts in your ~/.bashrc.
Source (HTML): https://games.aidebatehub.com/programs/linux/modern/zoxide.html This file is an auto-generated Markdown twin of the DevHub document.
AI Knowledge Hub
Visitor Comments