Configs2026年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.

AI
AI Open Source · Community
快速使用

先拿来用,再决定要不要深挖

这里应该同时让用户和 Agent 知道第一步该复制什么、安装什么、落到哪里。

# Install
brew install zoxide                        # macOS
curl -sSfL https://raw.githubusercontent.com/ajeetdsouza/zoxide/main/install.sh | sh
cargo install zoxide --locked

# Hook into shell
echo "eval \"\$(zoxide init zsh)\"" >> ~/.zshrc
echo "eval \"\$(zoxide init bash)\"" >> ~/.bashrc

Usage:

z tokrepo        # Jump to nearest dir matching tokrepo
z web            # Jump to your frequent web dir
zi               # Interactive fzf picker
z foo bar        # Match dirs containing both foo and bar
z -              # Go to previous dir
介绍

zoxide is a smarter cd command written in Rust. It learns which directories you use most frequently and lets you jump to any of them with a few keystrokes. Inspired by the classic z script and autojump, but faster and supporting every major shell.

What zoxide Does

  • Frecency ranking — frequency + recency scoring for visited dirs
  • z command — jump to any tracked dir by partial name
  • zi — interactive fuzzy picker (uses fzf)
  • Multi-keyword matchz proj api finds ~/code/myproject/api
  • Last dirz - toggles previous directory
  • Shell integrations — bash, zsh, fish, PowerShell, nushell, elvish, xonsh, cmd
  • Directly callablezoxide query foo for scripting

Architecture

Rust binary that maintains a SQLite-like flat-file database at ~/.local/share/zoxide/db.zo. Each time you cd, the shell hook calls zoxide add $PWD. The z command queries the DB and returns the best match. Interactive mode pipes candidates to fzf.

Self-Hosting

Local CLI tool.

Key Features

  • Cross-shell support
  • Frecency algorithm
  • Fast matching (Rust)
  • Fuzzy interactive mode (zi)
  • Import from z, autojump, fasd
  • Scripting friendly
  • Dead entries auto-cleaned
  • No database maintenance needed

Comparison

Tool Algorithm Shells Database
zoxide Frecency All Rust flat file
z (shell script) Frecency Bash/Zsh Text file
autojump Frequency Bash/Zsh/Fish Python
fasd Frecency Bash/Zsh Shell script

常见问题 FAQ

Q: 和 fzf 配合? A: zi 自动用 fzf。设 _ZO_FZF_OPTS 环境变量定制样式。

Q: 怎么迁移 z 数据? A: zoxide import --from z ~/.z。支持 autojump、fasd、z-lua 格式。

Q: Windows 能用? A: 能。PowerShell 和 cmd 都有 init hook。

来源与致谢 Sources

讨论

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

相关资产