yaziのインストール方法と初期設定
Rustで開発されたターミナルファイルマネージャ
rangerより後発なファイルマネージャであり、高速なファイルマネージャと公式では謳っている。
Linux, MacOS, Windowsどのプラットフォームでも利用可能。
以降ではUbuntu, Windowsでの導入方法についてまとめる。
Ubuntuでのインストール方法
https://yazi-rs.github.io/docs/installation#debian にしたがって依存パッケージをインストール
sudo apt install -y ffmpeg 7zip jq poppler-utils fd-find ripgrep fzf zoxide imagemagick
Ubuntuはaptで提供されていないので https://github.com/sxyazi/yazi/releases からバイナリをダウンロード
※snap版もあることに後から気づいたが今回はバイナリからのセットアップ方法について述べる
TARGET_VER="25.4.8"
wget -O ~/Downloads/yazi.zip https://github.com/sxyazi/yazi/releases/download/v${TARGET_VER}/yazi-x86_64-unknown-linux-musl.zip
cd ~/Downloads
unzip yazi.zip
mv yazi-x86_64-unknown-linux-musl/ yazi/
mv yazi/ ~/bin/
echo 'export PATH=$PATH:~/bin/yazi' >> ~/.bashrc
Ubuntuでの各種設定ファイル導入手順
バイナリからセットアップした場合は設定ファイル群が付属されていないので https://github.com/sxyazi/yazi.git
をcloneして~/.config/yazi
配下に必要なファイルを格納
mkdir -p ~/.config/yazi
git clone https://github.com/sxyazi/yazi.git ~/.config/yazi/yazi
git clone https://github.com/yazi-rs/flavors.git ~/.config/yazi/flavors
cd ~/.config/yazi
cp yazi/yazi-config/preset/keymap-default.toml ./keymap.toml
cp yazi/yazi-config/preset/yazi-default.toml ./yazi.toml
themeはflavorから参照したいので以下のように記述
# If the user's terminal is in dark mode, Yazi will load `theme-dark.toml` on startup; otherwise, `theme-light.toml`.
# You can override any parts of them that are not related to the dark/light mode in your own `theme.toml`.
# If you want to dynamically override their content based on dark/light mode, you can specify two different flavors
# for dark and light modes under `[flavor]`, and do so in those flavors instead.
"$schema" = "https://yazi-rs.github.io/schemas/theme.json"
# vim:fileencoding=utf-8:foldmethod=marker
# : Flavor {{{
[flavor]
dark = "dracula"
light = "catppuccin-latte"
# : }}}
Windowsでのインストール方法
https://github.com/sxyazi/yazi/releases からyazi-x86_64-pc-windows-msvc.zip
をダウンロードする
実行ファイル形式なのでインストールの必要はなし
Windowsでの各種設定ファイル導入手順
zipでインストールした場合は設定ファイルが付属されていないので%appdata%\yazi\config
配下に格納
mkdir %appdata%\yazi\config
git clone https://github.com/sxyazi/yazi.git %appdata%\yazi\yazi
git clone https://github.com/yazi-rs/flavors.git %appdata%\yazi\config\flavors
cd %appdata%\yazi
copy .\yazi\yazi-config\preset\yazi-default.toml .\config\yazi.toml
copy .\yazi\yazi-config\preset\keymap-default.toml .\config\keymap.toml
theme.tomlについてはUbuntuの節で記載したものと同様なので省略
各種設定ファイル変更点(Ubuntu, Windows共通)
■ yazi.toml
-
show_hidden
をtrue
に変更
隠しファイル表示パラメータ
■ keymap.toml
-
arrow prev
をarrow -1
に変更 -
arrow next
をarrow 1
に変更
plugin
機能性を拡張するプラグインが用意されているので現在導入しているものを紹介
なお、pluginはya
コマンドを用いてインストールする仕組みとなっている(前述の手順で解凍したzipにyazi
と一緒に格納されている)。
インストールしたpluginは
Ubuntuは~/.config/yazi/plugins
Windowsは%appdata%\yazi\config\plugins
が配置場所となる。
また、ya pack -l
のコマンドでインストール済みのpluginを確認することができる。
以下で筆者が追加したpluginの概要とデフォルトから変更した点について記述する。
セットアップ方法については各githubを参照。
full-border
■デフォルトでは最低限しか用意されていない境界線を追加する
セットアップが完了すると以降はyazi
を起動すると境界線が表示されるようになる。
smart-enter.yazi
■ディレクトリを移動するか、ファイルを開くかを一つのキーで実行することができる
READMEに従ってkeymap.toml
に以下を追記
[[manager.prepend_keymap]]
on = "<Enter>"
run = "plugin smart-enter"
desc = "Enter the child directory, or open the file"
l
から<Enter>
に変更している(ranger
と同様の操作にするため)
toggle-pane
■プレビューペインの表示/非表示機能の追加
READMEに従ってkeymap.toml
に以下を追記
# keymap.toml
[[manager.prepend_keymap]]
on = "T"
run = "plugin toggle-pane min-preview"
desc = "Show or hide the preview pane"
# keymap.toml
[[manager.prepend_keymap]]
on = "i"
run = "plugin toggle-pane max-preview"
desc = "Maximize or restore the preview pane"
- プレビューの最大化のキーバインドを
ranger
と同様にi
に変更
chmod
■yazi
を介してchmod
コマンドを実行することができる(Windowsは不可)
dedukun/bookmarks
■READMEに従ってkeymap.toml
に以下を追記(一部キーバインドを変更)
[[manager.prepend_keymap]]
on = [ "B", "S" ]
run = "plugin bookmarks save"
desc = "Save current position as a bookmark"
[[manager.prepend_keymap]]
on = [ "B", "J" ]
run = "plugin bookmarks jump"
desc = "Jump to a bookmark"
[[manager.prepend_keymap]]
on = [ "b", "d" ]
run = "plugin bookmarks delete"
desc = "Delete a bookmark"
[[manager.prepend_keymap]]
on = [ "b", "D" ]
run = "plugin bookmarks delete_all"
desc = "Delete all bookmarks"
- デフォルトのブックマーク保存キーバインドがlinemode変更のキーバインドと重複するので変更
- 併せてブックマークジャンプのキーバインドも変更
READMEに従ってinit.lua
に以下を追記
require("bookmarks"):setup({
last_directory = { enable = false, persist = false, mode="dir" },
persist = "all",
desc_format = "full",
file_pick_mode = "hover",
custom_desc_input = true,
notify = {
enable = true,
timeout = 3,
message = {
new = "New bookmark '<key>' -> '<folder>'",
delete = "Deleted bookmark in '<key>'",
delete_all = "Deleted all bookmarks",
},
},
})
-
persist
をall
に変更し、yazi
終了後もブックマークが保存されるように変更 -
custom_desc_input
をtrue
に変更しブックマーク保存時にブックマーク名を入力できるように変更 -
notify
機能を有効化し、timeout
を3秒に変更
git.yazi
■yazi
でgitのステータスをlinemodeに表示
jump-to-char.yazi
■vimライクにファイルを検索する(入力した文字列にヒットしたファイルに即座にフォーカスを当てる)
smart-filter.yazi
■連続フィルタリング機能
入力した文字列に対して一意なファイル・ディレクトリが決まった時に自動的にファイルなら開き、ディレクトリなら移動する
smart-tab
■公式のドキュメントで紹介されているプラグイン
フォルダフォーカスに時にtを入力した場合に自動的に新しいタブで開く
smart-switch
■公式のドキュメントで紹介されているプラグイン
2を入力した際に2タブがなければ自動的に作成してタブを開く(ranger
にも同様の機能があったはず)
2以降の数字も機能させたい場合は数字をインクリメントしたkeymapを追加で登録すればよい。
シェルラッパー
~/.bashrc
などに記述することでyazi
の挙動をカスタイマイズすることができる
■ yazi終了時に終了したディレクトリに移動
https://yazi-rs.github.io/docs/quick-start/#shell-wrapper に従って~/.bashrc
に以下を追加
function yazi_cd() {
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"
}
if which yazi >& /dev/null && [[ -t 1 ]]; then
bind '"\C-o":"yazi_cd\C-m"'
fi
※ranger
のranger_cd
に倣ってyazi_cd
とした。
また、ctrl + o
でyazi_cd
を起動できるように設定
Windowsの場合は以下をPATH
が通っているディレクトリに格納(yazi
と同じディレクトリ入れておくことを推奨)
@echo off
set tmpfile=%TEMP%\yazi-cwd.%random%
yazi %* --cwd-file="%tmpfile%"
:: If the file does not exist, then exit
if not exist "%tmpfile%" exit /b 0
:: If the file exist, then read the content and change the directory
set /p cwd=<"%tmpfile%"
if not "%cwd%"=="" (
cd /d "%cwd%"
)
del "%tmpfile%"
コマンドプロンプトは調べた限りではショートカットを追加でアサインする機能はないようなのでyazi_cd
と入力して起動
その他
■ linemodeの変更
yazi.toml#linemode | Yaziの記載を参考に独自のラインモードを実装
init.lua
に以下の記述を追加
function Linemode:size_and_mtime()
local time = math.floor(self._file.cha.mtime or 0)
if time == 0 then
time = ""
elseif os.date("%Y", time) == os.date("%Y") then
time = os.date("%m/%d %H:%M", time)
else
time = os.date("%Y/%m/%d", time)
end
local size = self._file:size()
return string.format("%s %s", time, size and ya.readable_size(size) or "-")
end
-
YYYY/MM/DD mm:dd ファイルの容量
で表示されるように変更 -
yazi.toml
のlinemode
の値を"size_and_mtime"
に変更
■ 画像プレビュー
Windows Terminalではv1.22.10352.0
からターミナル上での画像プレビューが可能となっており、yazi
も対応している。
他のクライアントツールの対応状況に関してはImage Preview | Yaziを参照
tmuxでプレビューするには以下のセットアップが必要
set -g allow-passthrough on
set -ga update-environment TERM
set -ga update-environment TERM_PROGRAM
tmux kill-server && tmux || tmux
■ 現在のディレクトリ上でシェルを開く
https://yazi-rs.github.io/docs/tips/#dropping-to-shell に従ってkeymap.toml
に以下を追加
Ubuntuの場合
[[manager.prepend_keymap]]
on = "!"
run = 'shell "$SHELL" --block'
desc = "Open shell here"
Windowsの場合
[[manager.prepend_keymap]]
on = "!"
run = 'shell "cmd.exe" --block'
desc = "Open Command Prompt here"
※powershell.exe
からcmd.exe
に変更している
Ubuntuの場合はさらに以下を~/.bashrc
に追記することで
yazi
経由でシェルを開いた際にプロンプトの末尾に(in yazi[$YAZI_LEVEL])
が出力され、視覚的にyazi
経由で開いたかを確認できる。
※$YAZI_LEVEL
はyazi
経由でシェルを開いた際のネスト数を指す。
[ -n "$YAZI_LEVEL" ] && PS1="$PS1"'(in yazi[$YAZI_LEVEL]) '
b-ryan/powerline-shellを使っている場合はbashの節の記述を以下のように変更
function _update_ps1() {
PS1="$(~/.local/bin/powerline-shell $?)"
[ -n "$YAZI_LEVEL" ] && PS1="$PS1"'(in yazi[$YAZI_LEVEL]) '
}
if [ "$TERM" != "linux" ]; then
PROMPT_COMMAND="_update_ps1; $PROMPT_COMMAND"
fi
余談だが、YAZI_LEVEL
についてドキュメントには特に記載はなかった。
同じくファイルマネージャのranger
にRANGER_LEVEL
という変数があったので、yazi
もあるだろうと思い、
githubで検索したところ、YAZI_LEVEL
の変数が存在したので、rangerと同様の記述をしたところ、同じ挙動となった。
■ Windowsでファイル・ディレクトリを削除した際の挙動について
yazi
を経由したファイル・ディレクトリの削除は完全に削除されるわけではなく、ごみ箱に一旦格納される。
■ Windowsでテキストファイルを開く際にvim(nvim)を指定
デフォルトではcode
が指定されているが、単一ファイルを開くためにわざわざvscodeを開くのは時間がかかる。
notepad
(メモ帳)なら起動は早いが、ターミナル上では開かないので出来ればUbuntu環境などと同様にターミナル上で編集を行いたい、
yazi.toml
の[opener]
のedit
の部分を以下のように変更することでテキストファイルを開く際にvim(nvim)で開くことができる。
[opener]
edit = [
{ run = '${EDITOR:-vi} "$@"', desc = "$EDITOR", block = true, for = "unix" },
{ run = 'nvim %*', block = true, desc = "nvim", for = "windows" },
{ run = 'nvim -w %*', block = true, desc = "nvim (block)", for = "windows" },
■ Windows Terminalでyaziのプロファイルを作成
Windows Terminalでyazi
用のプロファイルを作成しておくと簡単に起動できる。
tabColor
は適当に設定にしているのでお好みで変更を推奨。
なお、以下では水平分割して上半分はyazi
を下半分はcmd
を起動するように設定している。
yazi
呑み起動したい場合はコメントアウトしているcommandline
の使用すればよい。
{
"backgroundImage": null,
"backgroundImageOpacity": 0.1,
"colorScheme": "Solarized Dark",
// "commandline": "cmd.exe /k \"yazi_cd.cmd\"",
"commandline": "wt -w 0 --suppressApplicationTitle=true --title \"File Manager\" --tabColor \"#2E8555\" cmd.exe /k \"yazi_cd.cmd\"; split-pane -H --suppressApplicationTitle=true --size .30 --profile \"Command Prompt\" --title \"terminal\" --tabColor \"#00ffff\"",
"font":
{
"face": "Cascadia Code NF",
"size": 12
},
"guid": "{********-****-****-****-************}",
"icon": "🦆",
"name": "yazi",
"startingDirectory": "%USERPROFILE%\\Downloads",
"suppressApplicationTitle": true,
"tabColor": "#2E8555",
"tabTitle": "File Manager",
"useAcrylic": true
},
■ windowsへのmpvの導入方法
yazi
ではメディアプレイヤーとしてmpv
を採用している。
しかし、mpv-player/mpv: 🎥 Command line media playerの公式githubを確認してもインストーラは存在しない。
READMEには準公式ビルドとサードパーティ製パッケージからインストールする旨が記載されている。
Windowsの場合はmpvnet-player/mpv.net: 🎞 mpv.net is a media player for Windows with a modern GUI.から
setup.exe
をダウンロードしてインストールするのが手っ取り早い。
ただし、この場合実行ファイル名はmpv
ではなく、mpv.net
になるのでyazi.toml
のmpv
の記述をmpv.net
に変更する必要がある。
また、mpv.net
へのPATHも登録しておくこと。
設定が正しくできていれば、動画ファイルを開くとmpv
のウィンドウが起動し、動画ファイルが再生される。
Trouble Shooting
■ Windowsでファイルを開くことが出来ない
mimeタイプを判定するfile
コマンドが機能していないことが原因
Windowsではプリインストールされていないがgitをインストールしている場合は<Gitインストールディレクトリ>\usr\bin\file.exe
に格納されているので、
<Gitインストールディレクトリ>\usr\bin
にPATHを通すか、
YAZI_FILE_ONE
という環境変数を新たに作成し、<Gitインストールディレクトリ>\usr\bin\file.exe
を設定しておく。
■ Windowsで動画のサムネイルが表示されない
ffmpeg
がインストールされていないことが原因
winget
経由でインストール
winget install ffmpeg
wingetが使えない環境の場合はBuilds - CODEX FFMPEG @ gyan.devからffmpeg-git-full.7z
をインストール
解凍してbin配下のffmpeg.exe
, ffplay.exe
, ffprobe.exe
をPATHが通っているディレクトリに格納
■ yazi経由でfzfやzoxideを使用するとエラーが発生する
どちらも最新版にすると改善する可能性がある。
以下からそれぞれ最新版をダウンロード
筆者の環境では以下のバージョンの組み合わせで動作することを確認
$ yazi --version
Yazi 25.3.2 (VERGEN_IDEMPOTENT_OUTPUT 2025-03-02)
$ fzf --version
0.61.1 (93cb3758)
$ zoxide --version
zoxide 0.9.7
■ yaziを使う上で不足している設定がわからない
yazi --debug
で現在の設定状態を確認することができる。
不足しているパッケージなどは適宜インストールすること。
reference
- sxyazi/yazi: 💥 Blazing fast terminal file manager written in Rust, based on async I/O.
- Configuration | Yazi
- Installation | Yazi
- Frequently Asked Questions#why-cant-preview | Yazi
- How to set nvim as opener for files? (windows) · sxyazi/yazi · Discussion #1600
- 【CLIファイルファインダー】yazi #初心者 - Qiita
- junegunn/fzf: :cherry_blossom: A command-line fuzzy finder
- ajeetdsouza/zoxide: A smarter cd command. Supports all major shells.
- Builds - CODEX FFMPEG @ gyan.dev
- mpv-player/mpv: 🎥 Command line media player
- mpvnet-player/mpv.net: 🎞 mpv.net is a media player for Windows with a modern GUI.
Discussion