mcpField
Z
zoxide

zoxide

官方
github.com开发者工具40.3kzoxide4 天前更新
代码仓库访问官网

关于 zoxide

跟踪目录导航模式并按访问频率对目录排序。通过最少输入提供快捷方式跳转到常访文件夹。

主要功能

  1. 01通过部分名称快速跳转到目录而无需输入完整路径
  2. 02自动学习和追踪导航模式及其频率
  3. 03集成到 Shell 初始化中以启用 z 命令快捷方式

适用场景

  1. 01通过几个字符跳转项目来减少目录导航时间
  2. 02避免反复输入常访文件夹的完整路径
  3. 03使用智能目录完成简化 Shell 工作流

安装

选择你的系统或包管理器,复制命令到终端运行。

$
brew install zoxide

安装完成后运行zoxide --version确认安装成功。

命令示例

常用命令按使用顺序排列。

01
zoxide init zsh
02
z project

详细介绍

特别鸣谢:

  <a href="https://go.warp.dev/zoxide"><img alt="由 Warp 赞助" width="230" src="https://raw.githubusercontent.com/warpdotdev/brand-assets/refs/heads/main/Github/Sponsor/Warp-Github-LG-03.png" /></a>
  <div><sup><b>Warp,专为使用多个 AI Agent 进行编码而打造。</b></sup></div>
  <div><sup>支持 macOS、Linux 和 Windows。</sup></div>
  <div><sup>
    访问
    <a href="https://go.warp.dev/zoxide"><u>warp.dev</u></a>
    了解更多。
  </sup></div>
</td>
<td align="center">
  
  <a href="https://www.recall.ai/careers?ashby_jid=7b02811e-bc91-4ef2-925d-f56a5acac13b&utm_source=github&utm_medium=sponsorship&utm_campaign=zoxide"><img alt="由 Recall.ai 赞助" width="230" src="https://github.com/user-attachments/assets/0c5cb177-561c-4637-bef6-cf584939c829" /></a>
  <div><sup>峰值负载时每秒处理超过 3TB 视频,</sup></div>
  
  <div><sup>现<a href="https://www.recall.ai/careers?ashby_jid=7b02811e-bc91-4ef2-925d-f56a5acac13b&utm_source=github&utm_medium=sponsorship&utm_campaign=zoxide">正在旧金山招聘。</a></sup></div>
</td>

zoxide 标志
zoxide

[![crates.io][crates.io-badge]][crates.io] [![下载量][downloads-badge]][releases] [![使用 Nix 构建][builtwithnix-badge]][builtwithnix]

zoxide 是一款更智能的 cd 命令,灵感来自 z 和 autojump。

它会记住你最常使用的目录,让你只需敲击几下键盘就能“跳转”到这些目录。
zoxide 适用于所有主流 Shell。

快速入门 • 安装 • 配置 • 集成

快速入门

![教程][tutorial]

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<SPACE><TAB>  # show interactive completions (bash 4.4+/fish/zsh only)

[此处][algorithm-matching]可了解有关匹配算法的更多信息。

安装

只需 4 个简单步骤即可安装 zoxide:

  1. 安装二进制文件

    zoxide 可在大多数主流平台上运行。如果你的平台未列在下方, 请[提交问题][issues]。

    Linux / WSL > 推荐通过安装脚本安装 zoxide: > > ```sh > curl -sSfL https://raw.githubusercontent.com/ajeetdsouza/zoxide/main/install.sh | sh > ``` > > 或者,你也可以使用包管理器: > > | 发行版 | 软件源 | 安装说明 | > | ------------------- | ----------------------- | ----------------------------------------------------------------- | > | **_任意_** | **[crates.io]** | `cargo install zoxide --locked` | > | _任意_ | [conda-forge] | `conda install -c conda-forge zoxide` | > | _任意_ | [guix] | `guix install zoxide` | > | _任意_ | [Linuxbrew] | `brew install zoxide` | > | _任意_ | [nixpkgs] | `nix-env -iA nixpkgs.zoxide` | > | Alpine Linux 3.13+ | [Alpine Linux Packages] | `apk add zoxide` | > | Arch Linux | [Arch Linux Extra] | `pacman -S zoxide` | > | ~~Debian~~[^1] | ~~[Debian Packages]~~ | ~~`apt install zoxide`~~ | > | Devuan 4.0+ | [Devuan Packages] | `apt install zoxide` | > | Exherbo Linux | [Exherbo packages] | `cave resolve -x repository/rust`
    `cave resolve -x zoxide` | > | Fedora 32+ | [Fedora Packages] | `dnf install zoxide` | > | Gentoo | [Gentoo Packages] | `emerge app-shells/zoxide` | > | Manjaro | | `pacman -S zoxide` | > | openSUSE Tumbleweed | [openSUSE Factory] | `zypper install zoxide` | > | ~~Parrot OS~~[^1] | | ~~`apt install zoxide`~~ | > | ~~Raspbian~~[^1] | ~~[Raspbian Packages]~~ | ~~`apt install zoxide`~~ | > | Rhino Linux | [Pacstall Packages] | `pacstall -I zoxide-deb` | > | Slackware 15.0+ | [SlackBuilds] | [安装说明][slackbuilds-howto] | > | Solus | [Solus Packages] | `eopkg install zoxide` | > | ~~Ubuntu~~[^1] | ~~[Ubuntu Packages]~~ | ~~`apt install zoxide`~~ | > | Void Linux | [Void Linux Packages] | `xbps-install -S zoxide` |
    macOS

    要安装 zoxide,请使用包管理器:

    软件源安装说明
    [crates.io]cargo install zoxide --locked
    [Homebrew]brew install zoxide
    [conda-forge]conda install -c conda-forge zoxide
    [MacPorts]port install zoxide
    [nixpkgs]nix-env -iA nixpkgs.zoxide

    或者,在终端中运行以下命令:

    curl -sSfL https://raw.githubusercontent.com/ajeetdsouza/zoxide/main/install.sh | sh
    
    Windows > zoxide 可用于 PowerShell,以及在 Cygwin、Git Bash 和 MSYS2 中运行的 shell。 > > 推荐通过 `winget` 安装 zoxide: > > ```sh > winget install ajeetdsouza.zoxide > ``` > > 或者,也可以使用其他包管理器: > > | 仓库 | 安装说明 | > | --------------- | ------------------------------------- | > | **[crates.io]** | `cargo install zoxide --locked` | > | [Chocolatey] | `choco install zoxide` | > | [conda-forge] | `conda install -c conda-forge zoxide` | > | [Scoop] | `scoop install zoxide` | > > 如果你使用 Cygwin、Git Bash 或 MSYS2,也可以使用安装脚本: > > ```sh > curl -sSfL https://raw.githubusercontent.com/ajeetdsouza/zoxide/main/install.sh | sh > ```
    BSD

    安装 zoxide,请使用包管理器:

    发行版仓库安装说明
    任意[crates.io]cargo install zoxide --locked
    DragonFly BSD[DPorts]pkg install zoxide
    FreeBSD[FreshPorts]pkg install zoxide
    NetBSD[pkgsrc]pkgin install zoxide

    或者,在终端中运行此命令:

    curl -sS https://raw.githubusercontent.com/ajeetdsouza/zoxide/main/install.sh | bash
    
    Android

    安装 zoxide,请使用包管理器:

    仓库安装说明
    [Termux]pkg install zoxide

    或者,在终端中运行此命令:

    curl -sS https://raw.githubusercontent.com/ajeetdsouza/zoxide/main/install.sh | bash
    
  2. 在 shell 中设置 zoxide

    要开始使用 zoxide,请将其添加到你的 shell 中。

    Bash

    将以下内容添加到配置文件的末尾(通常是 ~/.bashrc):

    eval "$(zoxide init bash)"
    
    Elvish

    将以下内容添加到配置文件的末尾(通常是 ~/.elvish/rc.elv):

    eval (zoxide init elvish | slurp)
    

    注意: zoxide 仅支持 elvish v0.18.0 及以上版本。

    Fish

    将以下内容添加到配置文件的末尾(通常是 ~/.config/fish/config.fish):

    zoxide init fish | source
    
    Nushell

    将以下内容添加到 env 文件的末尾(在 Nushell 中运行 $nu.env-path 即可找到该文件):

    zoxide init nushell | save -f ~/.zoxide.nu
    

    然后,将以下内容添加到配置文件的末尾(在 Nushell 中运行 $nu.config-path 即可找到该文件):

    source ~/.zoxide.nu
    

    注意: zoxide 仅支持 Nushell v0.106.0 及以上版本。

    PowerShell

    将以下内容添加到配置文件的末尾(在 PowerShell 中运行 echo $profile 即可找到该文件):

    Invoke-Expression (& { (zoxide init powershell | Out-String) })
    
    Tcsh

    将以下内容添加到配置文件的末尾(通常是 ~/.tcshrc):

    zoxide init tcsh > ~/.zoxide.tcsh
    source ~/.zoxide.tcsh
    
    Xonsh > 将以下内容添加到配置文件的 **末尾**(通常是 `~/.xonshrc`): > > ```python > execx($(zoxide init xonsh), 'exec', __xonsh__.ctx, filename='zoxide') > ```
    Zsh

    将以下内容添加到配置文件的 末尾(通常是 ~/.zshrc):

    eval "$(zoxide init zsh)"
    

    要使补全功能正常工作,必须在调用 compinit 之后 添加上述命令。你可能需要运行 rm ~/.zcompdump*; compinit 来重建补全缓存。

    任意 POSIX shell

    将以下内容添加到配置文件的 末尾:

    eval "$(zoxide init posix --hook prompt)"
    

    注意: [Warp] 提供了自己的补全功能,因此不支持 Space+Tab 补全。

  3. 安装 fzf (可选)

    [fzf] 是一款命令行模糊查找工具,zoxide 使用它来实现补全/交互式选择。可从[此处][fzf-installation]安装。

    注意: 支持的 fzf 最低版本为 v0.51.0。

  4. 导入数据 (可选)

    如果你目前正在使用以下任一插件,可以考虑将数据导入 zoxide。数据文件会根据各插件的标准约定自动检测。

    zoxide import <plugin>
    
    插件命令
    atuinzoxide import atuin
    autojumpzoxide import autojump
    fasdzoxide import fasd
    zzoxide import z
    z.luazoxide import z.lua
    zsh-zzoxide import zsh-z

配置

标志

调用 zoxide init 时,可使用以下标志:

  • --cmd

    • 更改 z 和 zi 命令的前缀。
    • --cmd j 会将命令改为(j、ji)。
    • --cmd cd 会替换 cd 命令。
  • --hook <HOOK>

    • 更改 zoxide 增加目录评分的频率:

      Hook说明
      none从不
      prompt每次 shell 提示符出现时
      pwd (default)每当目录发生更改时
  • --no-cmd

    • 阻止 zoxide 定义 z 和 zi 命令。
    • 如果你想重新定义这些函数,它们仍可在 shell 中通过 __zoxide_z 和 __zoxide_zi 使用。
环境变量

可使用环境变量1进行配置。必须在调用 zoxide init 之前设置。

  • _ZO_DATA_DIR

    • 指定数据库的存储目录。

    • 默认值因操作系统而异:

      操作系统路径示例
      Linux / BSD$XDG_DATA_HOME/zoxide 或 $HOME/.local/share/zoxide/home/alice/.local/share/zoxide
      macOS$HOME/Library/Application Support/zoxide/Users/Alice/Library/Application Support/zoxide
      Windows%LOCALAPPDATA%\zoxideC:\Users\Alice\AppData\Local\zoxide
  • _ZO_ECHO

    • 设置为 1 时,z 会在导航到匹配的目录之前打印该目录。
  • _ZO_EXCLUDE_DIRS

    • 将指定目录排除在数据库之外。

    • 此变量以列表形式提供,使用操作系统特定的字符分隔 [glob][glob]:

      操作系统分隔符示例
      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 会在将目录添加到数据库之前解析符号链接。

第三方集成

应用描述插件
[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 会话管理器原生支持
[superfile]文件管理器[原生支持][superfile-plugins]
[telescope.nvim]Neovim 的模糊查找器[telescope-zoxide]
[tmux-session-wizard]tmux 会话管理器原生支持
[tmux-sessionx]tmux 会话管理器原生支持
[vim] / [neovim]文本编辑器[zoxide.vim]
[xplr]文件管理器[zoxide.xplr]
[xxh]通过 SSH 传输 shell 配置[xxh-plugin-prerun-zoxide]
[yazi]文件管理器原生支持
[zabb]查找路径的最短可行查询原生支持
[zesh]zellij 会话管理器原生支持
[zsh-autocomplete]zsh 实时补全原生支持

Footnotes

  1. 如果你不确定如何在 shell 中设置环境变量,请参阅 [wiki][wiki-env]。 [aerc]: https://github.com/rjarry/aerc [alfred]: https://www.alfredapp.com/ [alfred-zoxide]: https://github.com/yihou/alfred-zoxide [algorithm-aging]: https://github.com/ajeetdsouza/zoxide/wiki/Algorithm#aging [algorithm-matching]: https://github.com/ajeetdsouza/zoxide/wiki/Algorithm#matching [alpine linux packages]: https://pkgs.alpinelinux.org/packages?name=zoxide [arch linux extra]: https://archlinux.org/packages/extra/x86_64/zoxide/ [builtwithnix-badge]: https://img.shields.io/badge/builtwith-nix-7d81f7?logo=nixos&logoColor=white&style=flat-square [builtwithnix]: https://builtwithnix.org/ [chocolatey]: https://community.chocolatey.org/packages/zoxide [clink-zoxide]: https://github.com/shunsambongi/clink-zoxide [clink]: https://github.com/mridgers/clink [conda-forge]: https://anaconda.org/conda-forge/zoxide [crates.io-badge]: https://img.shields.io/crates/v/zoxide?logo=rust&logoColor=white&style=flat-square [crates.io]: https://crates.io/crates/zoxide [debian packages]: https://packages.debian.org/stable/admin/zoxide [exherbo packages]: https://gitlab.exherbo.org/exherbo/rust/-/tree/master/packages/sys-apps/zoxide [devuan packages]: https://pkginfo.devuan.org/cgi-bin/package-query.html?c=package&q=zoxide [downloads-badge]: https://img.shields.io/github/downloads/ajeetdsouza/zoxide/total?logo=github&logoColor=white&style=flat-square [dports]: https://github.com/DragonFlyBSD/DPorts/tree/master/sysutils/zoxide [emacs]: https://www.gnu.org/software/emacs/ [fedora packages]: https://src.fedoraproject.org/rpms/rust-zoxide [felix]: https://github.com/kyoheiu/felix [freshports]: https://www.freshports.org/sysutils/zoxide/ [fzf-installation]: https://github.com/junegunn/fzf#installation [fzf-man]: https://junegunn.github.io/fzf/reference/ [fzf]: https://github.com/junegunn/fzf [gentoo packages]: https://packages.gentoo.org/packages/app-shells/zoxide [glob]: https://man7.org/linux/man-pages/man7/glob.7.html [guix]: https://packages.guix.gnu.org/packages/zoxide/ [homebrew]: https://formulae.brew.sh/formula/zoxide [issues]: https://github.com/ajeetdsouza/zoxide/issues/new [joshuto]: https://github.com/kamiyaa/joshuto [lf]: https://github.com/gokcehan/lf [lf-wiki]: https://github.com/gokcehan/lf/wiki/Integrations#zoxide [linuxbrew]: https://formulae.brew.sh/formula-linux/zoxide [macports]: https://ports.macports.org/port/zoxide/summary [neovim]: https://github.com/neovim/neovim [nixpkgs]: https://github.com/NixOS/nixpkgs/blob/master/pkgs/by-name/zo/zoxide/package.nix [nnn-autojump]: https://github.com/jarun/nnn/blob/master/plugins/autojump [nnn]: https://github.com/jarun/nnn [opensuse factory]: https://build.opensuse.org/package/show/openSUSE:Factory/zoxide [pacstall packages]: https://pacstall.dev/packages/zoxide-deb [pkgsrc]: https://pkgsrc.se/sysutils/zoxide [ranger-zoxide]: https://github.com/jchook/ranger-zoxide [ranger]: https://github.com/ranger/ranger [raspbian packages]: https://archive.raspbian.org/raspbian/pool/main/r/rust-zoxide/ [raycast]: https://www.raycast.com/ [raycast-zoxide]: https://www.raycast.com/mrpunkin/raycast-zoxide [releases]: https://github.com/ajeetdsouza/zoxide/releases [rfm]: https://github.com/dsxmachina/rfm [scoop]: https://github.com/ScoopInstaller/Main/tree/master/bucket/zoxide.json [sesh]: https://github.com/joshmedeski/sesh [slackbuilds]: https://slackbuilds.org/repository/15.0/system/zoxide/ [slackbuilds-howto]: https://slackbuilds.org/howto/ [solus packages]: https://github.com/getsolus/packages/tree/main/packages/z/zoxide/ [superfile]: https://github.com/yorukot/superfile [superfile-plugins]: https://superfile.dev/list/plugin-list/ [telescope-zoxide]: https://github.com/jvgrootveld/telescope-zoxide [telescope.nvim]: https://github.com/nvim-telescope/telescope.nvim [termux]: https://github.com/termux/termux-packages/tree/master/packages/zoxide [tmux-session-wizard]: https://github.com/27medkamal/tmux-session-wizard [tmux-sessionx]: https://github.com/omerxx/tmux-sessionx [tutorial]: contrib/tutorial.gif [ubuntu packages]: https://packages.ubuntu.com/jammy/zoxide [vim]: https://github.com/vim/vim [void linux packages]: https://github.com/void-linux/void-packages/tree/master/srcpkgs/zoxide [warp]: https://www.warp.dev [wiki-env]: https://github.com/ajeetdsouza/zoxide/wiki/HOWTO:-set-environment-variables "HOWTO: set environment variables" [xplr]: https://github.com/sayanarijit/xplr [xxh-plugin-prerun-zoxide]: https://github.com/xxh/xxh-plugin-prerun-zoxide [xxh]: https://github.com/xxh/xxh [yazi]: https://github.com/sxyazi/yazi [zabb]: https://github.com/Mellbourn/zabb [zesh]: https://github.com/roberte777/zesh [zoxide.el]: https://gitlab.com/Vonfry/zoxide.el [zoxide.vim]: https://github.com/nanotee/zoxide.vim [zoxide.xplr]: https://github.com/sayanarijit/zoxide.xplr [zsh-autocomplete]: https://github.com/marlonrichert/zsh-autocomplete ↩

评论

支持 Markdown