ajeetdsouza/zoxide

GitHub: ajeetdsouza/zoxide

智能目录跳转工具,通过记忆常用路径和模糊匹配实现快速导航。

Stars: 34278 | Forks: 745

Sponsored by Warp
Warp, built for coding with multiple AI agents.
Available for macOS, Linux, and Windows.
Visit warp.dev to learn more.
Sponsored by Recall.ai
Processing over 3TB/s of video at peak load,
now hiring in SF.

# zoxide [![crates.io](https://img.shields.io/crates/v/zoxide?logo=rust&logoColor=white&style=flat-square)][crates.io] [![Downloads](https://img.shields.io/github/downloads/ajeetdsouza/zoxide/total?logo=github&logoColor=white&style=flat-square)][releases] [![Built with Nix](https://img.shields.io/badge/builtwith-nix-7d81f7?logo=nixos&logoColor=white&style=flat-square)][builtwithnix] zoxide 是一个**更智能的 cd 命令**,灵感来源于 z 和 autojump。 它会记住你最常使用的目录,这样你只需敲击几下键盘就可以“跳转”到它们。
zoxide 支持所有主流 shell。 [入门指南](#getting-started) • [安装](#installation) • [配置](#configuration) • [集成](#third-party-integrations)
## 入门指南 ![Tutorial](https://static.pigsec.cn/wp-content/uploads/repos/2026/03/97097f569a045710.webp) ``` z foo # cd into highest ranked directory matching foo z foo bar # cd into highest ranked directory matching foo and bar z foo / # cd into a subdirectory starting with foo z ~/foo # z also works like a regular cd command z foo/ # cd into relative path z .. # cd one level up z - # cd into previous directory zi foo # cd with interactive selection (using fzf) z foo # show interactive completions (bash 4.4+/fish/zsh only) ``` 在[这里][algorithm-matching]阅读更多关于匹配算法的信息。 ## 安装 只需 4 个简单步骤即可安装 zoxide: 1. **安装二进制文件** zoxide 可在大多数主流平台上运行。如果下文未列出你的平台,请[提交 issue][issues]。
Linux / WSL
macOS
Windows
BSD
Android
2. **在你的 shell 上设置 zoxide** 要开始使用 zoxide,请将其添加到你的 shell 中。
Bash
Elvish
Fish
Nushell
PowerShell
Tcsh
Xonsh
Zsh
Any POSIX shell
3. **安装 fzf** (可选) [fzf] 是一个命令行模糊查找器,zoxide 使用它进行补全 / 交互式选择。你可以从[这里][fzf-installation]安装它。 4. **导入你的数据** (可选) 如果你目前正在使用以下任何插件,你可能希望将数据导入到 zoxide 中:
autojump
fasd, z, z.lua, zsh-z
ZLocation
## 配置 ### Flags 调用 `zoxide init` 时,可以使用以下 flags: - `--cmd` - 更改 `z` 和 `zi` 命令的前缀。 - `--cmd j` 会将命令更改为 (`j`, `ji`)。 - `--cmd cd` 会替换 `cd` 命令。 - `--hook ` - 更改 zoxide 增加目录分数的频率: | Hook | Description | | --------------- | --------------------------------- | | `none` | 从不 | | `prompt` | 每次shell提示符出现时 | | `pwd` (default) | 每当目录更改时 | - `--no-cmd` - 阻止 zoxide 定义 `z` 和 `zi` 命令。 - 如果你选择重新定义这些函数,它们在你的 shell 中仍然可用,名称为 `__zoxide_z` 和 `__zoxide_zi`。 ### 环境变量 环境变量[^2]可用于配置。它们必须在调用 `zoxide init` 之前设置。 - `_ZO_DATA_DIR` - 指定存储数据库的目录。 - 默认值因操作系统而异: | OS | Path | Example | | ----------- | ---------------------------------------- | ------------------------------------------ | | Linux / BSD | `$XDG_DATA_HOME` 或 `$HOME/.local/share` | `/home/alice/.local/share` | | macOS | `$HOME/Library/Application Support` | `/Users/Alice/Library/Application Support` | | Windows | `%LOCALAPPDATA%` | `C:\Users\Alice\AppData\Local` | - `_ZO_ECHO` - 设置为 1 时,`z` 将在导航到匹配目录之前打印该目录。 - `_ZO_EXCLUDE_DIRS` - 从数据库中排除指定的目录。 - 这是一个 [globs][glob] 列表,由特定于操作系统的字符分隔: | OS | Separator | Example | | ------------------- | --------- | ----------------------- | | Linux / macOS / BSD | `:` | `$HOME:$HOME/private/*` | | Windows | `;` | `$HOME;$HOME/private/*` | - 默认情况下,这设置为 `"$HOME"`。 - `_ZO_FZF_OPTS` - 在交互式选择期间传递给 [fzf] 的自定义选项。有关选项列表,请参见 [`man fzf`][fzf-man]。 - `_ZO_MAXAGE` - 配置 [老化算法][algorithm-aging],该算法限制数据库中的最大条目数。 - 默认情况下,这设置为 10000。 - `_ZO_RESOLVE_SYMLINKS` - 设置为 1 时,`z` 将在将目录添加到数据库之前解析符号链接。 ## 第三方集成 | Application | Description | Plugin | | --------------------- | -------------------------------------------- | -------------------------- | | [aerc] | 电子邮件客户端 | 原生支持 | | [alfred] | macOS 启动器 | [alfred-zoxide] | | [clink] | 改进的 Windows cmd.exe | [clink-zoxide] | | [emacs] | 文本编辑器 | [zoxide.el] | | [felix] | 文件管理器 | 原生支持 | | [joshuto] | 文件管理器 | 原生支持 | | [lf] | 文件管理器 | 参见 [wiki][lf-wiki] | | [nnn] | 文件管理器 | [nnn-autojump] | | [ranger] | 文件管理器 | [ranger-zoxide] | | [raycast] | macOS 启动器 | [raycast-zoxide] | | [rfm] | 文件管理器 | 原生支持 | | [sesh] | `tmux` session 管理器 | 原生支持 | | [telescope.nvim] | Neovim 的模糊查找器 | [telescope-zoxide] | | [tmux-session-wizard] | `tmux` session 管理器 | 原生支持 | | [tmux-sessionx] | `tmux` session 管理器 | 原生支持 | | [vim] / [neovim] | 文本编辑器 | [zoxide.vim] | | [xplr] | 文件管理器 | [zoxide.xplr] | | [xxh] | 通过 SSH 传输 shell 配置 | [xxh-plugin-prerun-zoxide] | | [yazi] | 文件管理器 | 原生支持 | | [zabb] | 查找路径的最短可能查询 | 原生支持 | | [zesh] | `zellij` session 管理器 | 原生支持 | | [zsh-autocomplete] | zsh 的实时补全 | 原生支持 | [^1]: Debian / Ubuntu 衍生版更新软件包的速度非常慢。如果你使用的是这些发行版之一,请考虑改用安装脚本。 [^2]: 如果你不确定如何在 shell 上设置环境变量,请查看 [wiki][wiki-env]。
标签:Bash, CLI, Fish, HTTP 参数枚举, IPv6, PowerShell, Rust, Shell 扩展, SOC Prime, WiFi技术, zoxide, Zsh, 可视化界面, 开发工具, 效率工具, 模糊匹配, 目录跳转, 终端, 网络流量审计, 自动跳转, 访问频率排序, 路径导航, 通知系统