Skills2026年4月11日·1 分钟阅读

zoxide — A Smarter cd Command That Learns Your Habits

zoxide is a smarter cd command written in Rust. It tracks directories you visit and lets you jump to any of them with just a few keystrokes. Inspired by z and autojump. Works with bash, zsh, fish, PowerShell, nushell, and more.

Agent 就绪

先审查再安装

这个资产需要先审查。复制的指令会要求 Agent dry-run、列出写入项,确认后再继续。

Needs Confirmation · 64/100策略:需确认
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Single
信任
信任等级:Established
入口
step-1.md
先审查命令
npx -y tokrepo@latest install d3b64571-35cb-11f1-9bc6-00163e2b0d79 --target codex

先 dry-run,确认写入项后再运行此命令。

TL;DR
zoxide tracks your directory visits and lets you jump to any frequently-used directory with a few keystrokes via fuzzy matching.
§01

What it is

zoxide is a Rust-based replacement for the cd command that ranks directories by frequency and recency (a metric called frecency). Instead of typing full paths, you type z proj and zoxide jumps to ~/code/my-project because that is where you go most often when you type 'proj'.

It targets developers and sysadmins who navigate deeply nested directory trees dozens of times per day. zoxide works with every major shell: bash, zsh, fish, PowerShell, nushell, elvish, and Xonsh.

§02

How it saves time or tokens

Directory navigation is a constant tax in terminal workflows. A developer working on a monorepo might type cd ~/company/services/api/internal/handlers fifty times a week. With zoxide, after the first visit, z handlers gets you there instantly. The frecency algorithm prioritizes recent visits, so your navigation adapts as your work focus shifts.

For AI agent workflows, zoxide's z command reduces the length of shell scripts and instructions. Instead of hardcoding absolute paths, agents can use z with partial names.

§03

How to use

  1. Install zoxide:
# macOS
brew install zoxide

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

# Or via Cargo
cargo install zoxide --locked
  1. Add the shell hook to your config:
# For zsh (add to ~/.zshrc)
eval "$(zoxide init zsh)"

# For bash (add to ~/.bashrc)
eval "$(zoxide init bash)"
  1. Use z to jump and zi for interactive fuzzy selection.
§04

Example

# Basic usage
z tokrepo        # Jump to the most frecent dir matching 'tokrepo'
z web api        # Match dirs containing both 'web' and 'api'
z -              # Go to previous directory

# Interactive mode (requires fzf)
zi               # Opens fuzzy picker of all tracked directories

# Check what zoxide has learned
zoxide query --list
# /Users/dev/projects/tokrepo    12.5
# /Users/dev/work/web-api        8.2
# /Users/dev/dotfiles            3.1
§05

Related on TokRepo

§06

Common pitfalls

  • zoxide needs a shell hook to track directory changes. If you forget to add eval "$(zoxide init zsh)" to your rc file, it will never learn your habits.
  • The interactive mode (zi) requires fzf to be installed separately. Without fzf, zi is not available.
  • zoxide stores its database in ~/.local/share/zoxide/db.zo. If you wipe this file, all learned directory rankings are lost.

常见问题

How does zoxide compare to autojump or z.sh?+

zoxide is a Rust rewrite inspired by z and autojump. It is significantly faster, supports more shells (including PowerShell and nushell), and uses an improved frecency algorithm. It is a drop-in replacement for both.

Does zoxide work on Windows?+

Yes. zoxide supports PowerShell and cmd on Windows. Install via Scoop, Chocolatey, or download the binary from GitHub releases. Shell integration uses the same `zoxide init powershell` pattern.

Can I import my z or autojump database?+

Yes. zoxide provides import commands: `zoxide import --from z <file>` and `zoxide import --from autojump <file>`. This lets you migrate without losing your directory history.

What is frecency?+

Frecency combines frequency (how often you visit a directory) and recency (how recently you visited it). A directory you visited 10 times this week ranks higher than one you visited 50 times last year. The algorithm automatically decays old entries.

Does zoxide slow down my shell?+

No. The shell hook adds negligible overhead -- zoxide is written in Rust and the database lookup takes microseconds. Benchmarks show it is faster than the original z.sh script and autojump.

引用来源 (3)

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产