Yazi
如果你已经在使用 Vim/Neovim,那么你一定要试用一下 Yazi,因为 Yazi 的快捷键操作思路几乎是跟 Vim/Neovim 相同的。
什么是 Yazi
Blazing fast terminal file manager written in Rust, based on async I/O.
Yazi 备忘清单
这份快速参考备忘单提供了 Yazi 快速的终端文件管理的简要概述,以及 Yazi的基本操作。
入门
功能特点
- 跨平台支持:Yazi 支持 Linux、macOS 和 Windows,提供一致的跨平台体验
- 轻量高效:简洁设计,启动和操作快速,资源消耗低
- 插件扩展:支持插件安装,灵活扩展功能
- 文件操作:支持复制、剪切、粘贴、删除、重命名等操作,且支持批量和多选功能,提升效率
安装
| 系统 | 安装方法 |
|---|---|
| 使用 Cargo 安装 | cargo install yazi |
| Arch Linux | yay -S yazi |
| Debian/Ubuntu | 可以使用 Cargo 进行安装 |
| macOS (使用 Homebrew) | brew install yazi |
| Windows (使用 Carg) | cargo install yazi |
| Windows (使用 Scoop) | scoop install yazi |
使用方法
命令启动 Yazi
yazi查看 Yazi 的帮助文档
yazi --help常用的快捷键
导航
| 快捷键 | 操作说明 |
|---|---|
| h | 返回上一级目录 |
| j | 向下移动选中项 |
| k | 向上移动选中项 |
| l | 进入选中的目录或打开文件 |
更多导航命令
| 快捷键 | 操作说明 |
|---|---|
| K | 在预览中向上移动 5 个单位 |
| J | 在预览中向下移动 5 个单位 |
| g ⇒ g | 将光标移动到顶部 |
| G | 将光标移动到底部 |
| z | 通过 fzf 进入目录或显示文件(cd 或 reveal) |
| Z | 通过 zoxide 进入目录(cd) |
使用 J 和 K 可以让出现在预览窗格内的多页 PDF 文件进行翻页预览,同样的,也可以使用鼠标滚轮进行翻页。
选择操作
| 快捷键 | 操作说明 |
|---|---|
| Space | 切换当前悬停的文件/目录的选择状态 |
| v | 进入可视模式(选择模式) |
| V | 进入可视模式(取消模式) |
| Ctrl + a | 选择所有文件 |
| Ctrl + r | 反转当前所有文件的选择状态 |
| Esc | 取消所有选择 |
用于选择文件和目录的快捷键命令
文件操作
| 快捷键 | 操作说明 |
|---|---|
| o | 打开选中的文件 |
| O | 以交互方式打开选中的文件 |
| Enter | 打开选中的文件 |
| Shift + Enter | 以交互方式打开选中的文件(部分终端尚不支持) |
| Tab | 显示文件信息 |
| y | 复制选中的文件 |
| x | 剪切选中的文件 |
| p | 粘贴已复制/剪切的文件 |
| P | 粘贴已复制/剪切的文件(如目标存在则覆盖) |
| Y 或 X | 取消已复制/剪切状态 |
| d | 将选中的文件移至回收站 |
| D | 彻底删除选中的文件 |
| a | 新建文件(以 / 结尾表示新建目录) |
| r | 重命名选中的文件 |
| . | 切换隐藏文件的显示状态 |
更多文件操作命令如下:
| 快捷键 | 操作说明 |
|---|---|
| ; | 执行一个 Shell 命令 |
| : | 执行一个 Shell 命令(阻塞,直到命令完成) |
| - | 创建已复制文件的绝对路径符号链接 |
| _ | 创建已复制文件的相对路径符号链接 |
| Ctrl + - | 创建已复制文件的硬链接 |
要操作选中的文件或目录
复制路径
| 快捷键 | 操作说明 |
|---|---|
| c ⇒ c | 复制文件路径 |
| c ⇒ d | 复制目录路径 |
| c ⇒ f | 复制文件名 |
| c ⇒ n | 复制不带扩展名的文件名 |
复制路径 说明:c ⇒ d 表示先按下 c 键,然后按下 d 键。
搜索与过滤
| 快捷键 | 操作说明 |
|---|---|
| f | 过滤文件 |
| / | 查找下一个文件 |
| ? | 查找上一个文件 |
| n | 跳转到下一个匹配项 |
| N | 跳转到上一个匹配项 |
搜索文件
| 快捷键 | 操作说明 |
|---|---|
| s | 使用 fd 按名称搜索文件 |
| S | 使用 ripgrep 按内容搜索文件 |
| Ctrl + s | 取消当前进行中的搜索 |
排序
| 快捷键 | 操作说明 |
|---|---|
| , ⇒ m | 按修改 时间 排序 |
| , ⇒ M | 按修改 时间倒序 排序 |
| , ⇒ b | 按 创建时间 排序 |
| , ⇒ B | 按 创建时间 倒序排序 |
| , ⇒ e | 按文件 扩展名 排序 |
| , ⇒ E | 按文件 扩展名倒序 排序 |
| , ⇒ a | 按 字母顺序 排序 |
| , ⇒ A | 按 字母倒序 排序 |
| , ⇒ n | 按 自然 排序 |
| , ⇒ N | 按 自然倒序 排序 |
| , ⇒ s | 按文件 大小 排序 |
| , ⇒ S | 按文件 大小倒序 排序 |
| , ⇒ r | 随机 排序 |
对文件/目录进行排序说明: , ⇒ a 表示先按下 , 键,再按下 a 键。
多标签页
| 快捷键 | 操作说明 |
|---|---|
| t | 以当前工作目录创建新标签页 |
| 1, 2, ..., 9 | 切换到第 N 个标签页 |
| [ | 切换到上一个标签页 |
| ] | 切换到下一个标签页 |
| { | 当前标签页与上一个互换位置 |
| } | 当前标签页与下一个互换位置 |
| Ctrl + c | 关闭当前标签页 |
自定义配置
自定义
通过编辑配置文件来自定义 Yazi,配置文件通常位于 $HOME/.config/yazi/xxx.toml,可修改默认设置如快捷键、主题等。
yazi.toml- 常规配置keymap.toml- 快捷键绑定theme.toml- 主题配置
配置文件示例:yazi.toml
[general]
# 设置主界面主题为 dark 或 light
theme = "dark"启动时的默认路径
default_path = "~"是否启用自动保存配置
auto_save_config = true自定义快捷键绑定
[keybindings]
quit = "q" # 退出
copy = "y" # 复制文件
paste = "p" # 粘贴文件
delete = "d" # 删除文件界面相关配置
[ui]
preview_enabled = true # 是否启用文件预览
show_hidden_files = true # 显示隐藏文件
columns = 2 # 文件列表列数搜索行为配置
[search]
case_sensitive = false # 搜索是否区分大小写
search_timeout = 30 # 搜索超时时间(秒)排序规则配置
[sorting]
sort_by = "name" # 排序方式: name,size,date
reverse_sort = false # 是否反向排序插件加载配置
[plugins]
enabled_plugins = ["git", "archive"]keymap.toml 配置示例
# 全局快捷键配置
[global]
# 全局退出应用程序
quit = "Ctrl+Q"
# 打开文件或目录
open = "Enter"
# 返回上级目录
back = "Backspace"
# 搜索功能触发
search = "/"
# 复制路径
copy_path = "Ctrl+C"
# 窗口控制快捷键
[window]
# 切换窗口
switch_window = "Tab"
# 新建窗口
new_window = "Ctrl+N"
# 关闭窗口
close_window = "Ctrl+W"
# 文件操作快捷键
[file]
# 删除文件
delete_file = "D"
# 重命名文件
rename_file = "R"
# 复制文件
copy_file = "Y"
# 粘贴文件
paste_file = "P"
# 移动文件
move_file = "M"
# 文件选择快捷键
[selection]
# 全选
select_all = "Ctrl+A"
# 取消所有选择
deselect_all = "Ctrl+D"
# 反选
invert_selection = "Ctrl+I"
# 选择当前文件/目录
select_item = "Space"
# 页面导航快捷键
[navigation]
# 向上移动光标
move_up = "K"
# 向下移动光标
move_down = "J"
# 向左切换标签
move_left = "H"
# 向右切换标签
move_right = "L"
# 自定义命令触发键
[custom]
# 触发自定义功能
custom_action_1 = "Ctrl+1"
custom_action_2 = "Ctrl+2"
custom_action_3 = "Ctrl+3"theme.toml 配置示例
[general]
# 设置主界面配色方案
background_color = "#1e1e2e" # 背景颜色
foreground_color = "#cdd6f4" # 文本颜色
cursor_color = "#89dceb" # 光标颜色
selection_color = "#585b70" # 选中项背景颜色
highlight_color = "#fab387" # 高亮颜色
# 字体设置
font_family = "FiraCode" # 字体名称
font_size = 14 # 字体大小
[ui]
# 界面边框与间距
border_color = "#45475a" # 边框颜色
padding = 4 # 界面内容的内边距
[file_browser]
# 文件浏览器颜色配置
directory_color = "#89b4fa" # 目录名称颜色
file_color = "#cdd6f4" # 普通文件颜色
symlink_color = "#f5c2e7" # 符号链接颜色
hidden_file_color = "#6c7086" # 隐藏文件颜色
[status_bar]
# 状态栏颜色
background_color = "#313244" # 状态栏背景
foreground_color = "#a6adc8" # 状态栏文字
error_color = "#f38ba8" # 状态栏错误信息
[search]
# 搜索结果配色
match_color = "#a6e3a1" # 搜索结果的匹配高亮
current_match_color = "#fab387" # 当前匹配项的高亮
[progress_bar]
# 进度条的配色
filled_color = "#89dceb" # 已填充部分
empty_color = "#313244" # 未填充部分Keybindings
提示
For all keybindings, see the default keymap.toml file.
Navigation
To navigate between files and directories you can use the arrow keys ←, ↓, ↑ and → or Vim-like keys such as h, j, k, l:
| Key binding | Alternate key | Action |
|---|---|---|
| k | ↑ | Move the cursor up |
| j | ↓ | Move the cursor down |
| l | → | Enter hovered directory |
| h | ← | Leave the current directory and into its parent |
Further navigation actions can be found in the table below.
| Key binding | Action |
|---|---|
| K | Seek up 5 units in the preview |
| J | Seek down 5 units in the preview |
| g ⇒ g | Move cursor to the top |
| G | Move cursor to the bottom |
| z | Cd to a directory or reveal a file via fzf |
| Z | Cd to a directory via zoxide |
| g ⇒ Space | Cd to a directory or reveal a file via interactive prompt |
Selection
To select files and directories, the following actions are available.
| Key binding | Action |
|---|---|
| Space | Toggle selection of hovered file/directory |
| v | Enter visual mode (selection mode) |
| V | Enter visual mode (unset mode) |
| Ctrl + a | Select all files |
| Ctrl + r | Inverse selection of all files |
| Esc | Cancel selection |
File operations
To interact with selected files/directories use any of the actions below.
| Key binding | Action |
|---|---|
| o | Open selected files |
| O | Open selected files interactively |
| Enter | Open selected files |
| Shift + Enter | Open selected files interactively (some terminals don't support it yet) |
| Tab | Show the file information |
| y | Yank selected files (copy) |
| x | Yank selected files (cut) |
| p | Paste yanked files |
| P | Paste yanked files (overwrite if the destination exists) |
| Y or X | Cancel the yank status |
| d | Trash selected files |
| D | Permanently delete selected files |
| a | Create a file (ends with / for directories) |
| r | Rename selected file(s) |
| . | Toggle the visibility of hidden files |
Further file operation actions can be found in the table below.
| Key binding | Action |
|---|---|
| ; | Run a shell command |
| : | Run a shell command (block until finishes) |
| - | Symlink the absolute path of yanked files |
| _ | Symlink the relative path of yanked files |
| Ctrl + - | Hardlink yanked files |
Copy paths
To copy paths, use any of the following actions below.
Observation: c ⇒ d indicates pressing the c key followed by pressing the d key.
| Key binding | Action |
|---|---|
| c ⇒ c | Copy the file path |
| c ⇒ d | Copy the directory path |
| c ⇒ f | Copy the filename |
| c ⇒ n | Copy the filename without extension |
Filter files
| Key binding | Action |
|---|---|
| f | Filter files |
Find files
| Key binding | Action |
|---|---|
| / | Find next file |
| ? | Find previous file |
| n | Go to the next found |
| N | Go to the previous found |
Search files
| Key binding | Action |
|---|---|
| s | Search files by name using fd |
| S | Search files by content using ripgrep |
| Ctrl + s | Cancel the ongoing search |
Sorting
To sort files/directories use the following actions.
Observation: , ⇒ a indicates pressing the , key followed by pressing the a key.
| Key binding | Action |
|---|---|
| , ⇒ m | Sort by modified time |
| , ⇒ M | Sort by modified time (reverse) |
| , ⇒ b | Sort by birth time |
| , ⇒ B | Sort by birth time (reverse) |
| , ⇒ e | Sort by file extension |
| , ⇒ E | Sort by file extension (reverse) |
| , ⇒ a | Sort alphabetically |
| , ⇒ A | Sort alphabetically (reverse) |
| , ⇒ n | Sort naturally |
| , ⇒ N | Sort naturally (reverse) |
| , ⇒ s | Sort by size |
| , ⇒ S | Sort by size (reverse) |
| , ⇒ r | Sort randomly |
Multi-tab
| Key binding | Action |
|---|---|
| t ⇒ t | Create a new tab in CWD |
| 1, 2, ..., 9 | Switch to the N-th tab |
| [ | Switch to the previous tab |
| ] | Switch to the next tab |
| { | Swap current tab with previous tab |
| } | Swap current tab with next tab |
| Ctrl + c | Close the current tab |
