Skip to content
0

文章发布较早,内容可能过时,阅读注意甄别。

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 Linuxyay -S yazi
Debian/Ubuntu可以使用 Cargo 进行安装
macOS (使用 Homebrew)brew install yazi
Windows (使用 Carg)cargo install yazi
Windows (使用 Scoop)scoop install yazi

使用方法

命令启动 Yazi

sh
yazi

查看 Yazi 的帮助文档

sh
yazi --help

常用的快捷键

导航

快捷键操作说明
h返回上一级目录
j向下移动选中项
k向上移动选中项
l进入选中的目录或打开文件

更多导航命令

快捷键操作说明
K在预览中向上移动 5 个单位
J在预览中向下移动 5 个单位
gg将光标移动到顶部
G将光标移动到底部
z通过 fzf 进入目录或显示文件(cdreveal)
Z通过 zoxide 进入目录(cd)

使用 JK 可以让出现在预览窗格内的多页 PDF 文件进行翻页预览,同样的,也可以使用鼠标滚轮进行翻页。

选择操作

快捷键操作说明
Space切换当前悬停的文件/目录的选择状态
v进入可视模式(选择模式)
V进入可视模式(取消模式)
Ctrl + a选择所有文件
Ctrl + r反转当前所有文件的选择状态
Esc取消所有选择

用于选择文件和目录的快捷键命令

文件操作

快捷键操作说明
o打开选中的文件
O以交互方式打开选中的文件
Enter打开选中的文件
Shift + Enter以交互方式打开选中的文件(部分终端尚不支持)
Tab显示文件信息
y复制选中的文件
x剪切选中的文件
p粘贴已复制/剪切的文件
P粘贴已复制/剪切的文件(如目标存在则覆盖)
YX取消已复制/剪切状态
d将选中的文件移至回收站
D彻底删除选中的文件
a新建文件(以 / 结尾表示新建目录)
r重命名选中的文件
.切换隐藏文件的显示状态

更多文件操作命令如下:

快捷键操作说明
;执行一个 Shell 命令
:执行一个 Shell 命令(阻塞,直到命令完成)
-创建已复制文件的绝对路径符号链接
_创建已复制文件的相对路径符号链接
Ctrl + -创建已复制文件的硬链接

要操作选中的文件或目录

复制路径

快捷键操作说明
cc复制文件路径
cd复制目录路径
cf复制文件名
cn复制不带扩展名的文件名

复制路径 说明:cd 表示先按下 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

toml
[general]
# 设置主界面主题为 dark 或 light
theme = "dark"

启动时的默认路径

toml
default_path = "~"

是否启用自动保存配置

toml
auto_save_config = true

自定义快捷键绑定

toml
[keybindings]
quit = "q"        # 退出
copy = "y"        # 复制文件
paste = "p"       # 粘贴文件
delete = "d"      # 删除文件

界面相关配置

toml
[ui]
preview_enabled = true     # 是否启用文件预览
show_hidden_files = true   # 显示隐藏文件
columns = 2                # 文件列表列数

搜索行为配置

toml
[search]
case_sensitive = false  # 搜索是否区分大小写
search_timeout = 30     # 搜索超时时间(秒)

排序规则配置

toml
[sorting]
sort_by = "name" # 排序方式: name,size,date
reverse_sort = false  # 是否反向排序

插件加载配置

toml
[plugins]
enabled_plugins = ["git", "archive"]

keymap.toml 配置示例

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 配置示例

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.

To navigate between files and directories you can use the arrow keys , , and or Vim-like keys such as h, j, k, l:

Key bindingAlternate keyAction
kMove the cursor up
jMove the cursor down
lEnter hovered directory
hLeave the current directory and into its parent

Further navigation actions can be found in the table below.

Key bindingAction
KSeek up 5 units in the preview
JSeek down 5 units in the preview
ggMove cursor to the top
GMove cursor to the bottom
zCd to a directory or reveal a file via fzf
ZCd to a directory via zoxide
gSpaceCd to a directory or reveal a file via interactive prompt

Selection

To select files and directories, the following actions are available.

Key bindingAction
SpaceToggle selection of hovered file/directory
vEnter visual mode (selection mode)
VEnter visual mode (unset mode)
Ctrl + aSelect all files
Ctrl + rInverse selection of all files
EscCancel selection

File operations

To interact with selected files/directories use any of the actions below.

Key bindingAction
oOpen selected files
OOpen selected files interactively
EnterOpen selected files
Shift + EnterOpen selected files interactively (some terminals don't support it yet)
TabShow the file information
yYank selected files (copy)
xYank selected files (cut)
pPaste yanked files
PPaste yanked files (overwrite if the destination exists)
Y or XCancel the yank status
dTrash selected files
DPermanently delete selected files
aCreate a file (ends with / for directories)
rRename selected file(s)
.Toggle the visibility of hidden files

Further file operation actions can be found in the table below.

Key bindingAction
;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: cd indicates pressing the c key followed by pressing the d key.

Key bindingAction
ccCopy the file path
cdCopy the directory path
cfCopy the filename
cnCopy the filename without extension

Filter files

Key bindingAction
fFilter files

Find files

Key bindingAction
/Find next file
?Find previous file
nGo to the next found
NGo to the previous found

Search files

Key bindingAction
sSearch files by name using fd
SSearch files by content using ripgrep
Ctrl + sCancel 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 bindingAction
,mSort by modified time
,MSort by modified time (reverse)
,bSort by birth time
,BSort by birth time (reverse)
,eSort by file extension
,ESort by file extension (reverse)
,aSort alphabetically
,ASort alphabetically (reverse)
,nSort naturally
,NSort naturally (reverse)
,sSort by size
,SSort by size (reverse)
,rSort randomly

Multi-tab

Key bindingAction
ttCreate a new tab in CWD
1, 2, ..., 9Switch 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 + cClose the current tab
最近更新