鸭子是命令行工具,可以gui展示文件甚至是图片。
但是我发现只要经过一些简单的配置,让他来负责命令行上的文件移动和穿梭,就非常的方便。
首先安装鸭子:
https://yazi-rs.github.io/
简单介绍一下他自带的快捷键
a → 输入 notes/ → 创建 notes 文件夹
a → 输入 hello.txt → 创建 hello.txt 文件
r — 重命名
d 或 D — 删除
y — 复制(yank)
x — 剪切
p — 粘贴
/ - 搜索
Space — 选中多个文件
安装了鸭子之后,你可能看不到icon,全都是问号,这是因为没有安装Nerdfont字体,安装字体之后设置一下你的终端即可。 https://www.nerdfonts.com/font-downloads

接下来我们来配置一下 function 来配合鸭子使用。
linux和macOS的用户可以在~/.zshrc中添加以下内容:code .zshrc
function y() {
local tmp="$(mktemp -t "yazi-cwd.XXXXXX")" cwd
yazi "$@" --cwd-file="$tmp"
if cwd="$(command cat -- "$tmp")" && [ -n "$cwd" ] && [ "$cwd" != "$PWD" ]; then
builtin cd -- "$cwd"
fi
rm -f -- "$tmp"
}
export EDITOR="code"
windows用户可以在$PROFILE中添加以下内容: (powershell)
code $PROFILE
function y() {
# 创建一个临时文件来记录 Yazi 退出时的路径
$tmp = [System.IO.Path]::GetTempFileName()
# 运行 yazi,并让它在退出时把最后的路径写进临时文件
yazi --cwd-file="$tmp" $args
if (Test-Path $tmp) {
$cwd = Get-Content $tmp
if ($cwd -and $cwd -ne $pwd.Path) {
Set-Location $cwd
}
Remove-Item $tmp
}
}
这下就配置完毕了,你可以在命令行中输入 y 来打开鸭子,浏览文件目录,按下 Q 退出,命令行就会自动切换到你在鸭子中浏览的目录,非常方便。

另外我感觉默录默认是深蓝色,非常不好看。
linux和macOS的用户可以在~/.config/yazi/theme.toml
Windows用户可以在%APPDATA%\yazi\config\theme.toml
[filetype]
rules = [
# Directories
{ name = "*/", fg = "cyan", bold = true },
]
