0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

yazi-1: CLI file manager , created with Rust.

Last updated at Posted at 2025-03-13
  • 注意:以下の記事を参考にされ、問題が生じた場合、責任は負えません。
  • 基本的には私の忘備録です。
  • 使用環境は manjaro-linux と時々macです。
  • windowsでは利用できない設定があります。
  • 本文を英語で記載してますが、中学生レベルですので、容易に理解できると思います。
  • 英語で書くと、わかりにくいと思われる部分は、日本語にしてます。
  • link先に了解なく引用している部分がありますので、問題があればご連絡ください。
  • 質門に回答できるのかは不明です。

前置き:my favorite file manager.

ここ数年で、GUIからほぼCUI?の環境に移行しました。おかげで、GUIのfilemanger(explore, finder, Thunar etc)を使わなくなりました。マウス面倒だし。ただWEBは仕方ない。。。

lf: ここ数年、最も愛用利しているfile manager. Go言語

 長所:カスタマイズが容易。速い。複数の lf を跨いでコピーができる。vimのpluginあり。
 短所:previewの設定が面倒。

nnn: remoteのmount機能が素晴らしい。

 長所:packageの容量は小さいが高性能。sshfsなどでremoteを容易にmount。plugin多数。
 短所:小気味良いが、見た目がすこし味気ないか。pluginの設定が多少面倒。

vifm: 上記を利用できない環境で利用。classicなfiler。

 長所:上記よりは利用できる環境が多い気がする。keybindはvimとほぼ同じ。
 短所:機能が少ない。多少設定を弄らなと、使いにくいかも。
以下に良い解説がある。

閑話休題。私がyaziで注目しているのは

高速、多機能、preview機能(terminal上での)。

なかでもpreviewが素晴らしい。特にsshでログインしたremote-PCにあるfileの画像をterminal上で綺麗に表示できまる。 仕事で多量の画像を扱う私には欲しかった機能です。ただ、この機能を利用するにはterminalを選ぶ必要がある。(以下参照。)

Yazi shows remote PC's image file(right-side) cleary on terminal, after ssh log-in.

3-2_plugin-pr-remotePC-2.jpg

yaziの由来は中国語の「アヒル」のようです。高速な動作がうりなのに、「アヒル」とはjoke?

Yazi (means "duck") is a terminal file manager written in Rust, based on non-blocking async I/O.

The developer chose the name "Yazi" because it means "duck" in Chinese (鸭子). This name reflects the project's origins and adds a unique, memorable touch to the terminal file manager

今回はthemeを除いた設定を中心に紹介します。

0. Preparation

!! Attention!!

  • Read carefully following page, which include install, config, tips, etc...
  • require yazi version 25.2.26-1 or higher.

1. install (manjaro-linux)

## full install
sudo pacman -S yazi ffmpeg p7zip jq poppler fd ripgrep fzf zoxide imagemagick

## For a minimal installation, Yazi only.
sudo pacman -S yazi

If you like to use yazi on windows, mac etc, read this page.

Add follows to ~/.zshrc

move to yazi's current-working directory, finishing yazi.

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"
}

Add follows to .tmux.conf, for preview.

set -g allow-passthrough on
set -ga update-environment TERM
set -ga update-environment TERM_PROGRAM

2. config files

yazi.toml - General configuration.
keymap.toml - Keybindings configuration.
theme.toml - Color scheme configuration.

2-1. place config file at following directory.

mkdir -p ~/.config/yazi

2-2. Default config files on git. And download raw files from below.

3. Edit cofig files

!! require yazi version 25.2 or higher !!

3-1. yazi.toml

A. Reduce column 3 to 2 & show hidden. files

## modify manager sction.

 [manager]
  ## Set the value to 0 to hide the corresponding panel, 
  ## but at least one panel must be visible (non-zero).
  
  ratio          = [ 0, 1, 1 ]   ## 2 cols
  #ratio          = [ 1, 4, 3 ]  ## default 3 cols.

  ## show hidden files
  show_hidden    = true

default : 3-clos
3_yazi_col-3.jpg

mine : 2-cols. why need 3 cols...
3_yazi_col-2.jpg

B. customize image opner.

Because Yazi takes a few seconds to open images on WSL + Windows Terminal.
If you use yazi on linux & mac, you do not need.

## add following at the end of opener section
[opener] 

  my_img = [
      { run = '/usr/bin/viewnior "$1"',     desc = "Open", for = "linux" },
  ]

## modify open section

  [open]
  rules = [
      # Folder
      { name = "*/", use = [ "edit", "open", "reveal" ] },
      # Text
      { mime = "text/*", use = [ "edit", "reveal" ] },
      # Image
  #   { mime = "image/*", use = [ "open", "reveal" ] },   ## default
      { mime = "image/*", use = [ "my_img", "reveal" ] }, ## mine
      # Media
      { mime = "{audio,video}/*", use = [ "play", "reveal" ] },

3-2. key.tmol

!! Attention !!

  • 記載方法にprepend とappendがあり、配置する場所に注意。
    概ねprependを使って、defaultの前に配置すれば、dafeultのkey-bindingsを上書きできる?

  • pluginはここに記載して、利用するようだ。

In each layer, there are two attributes: prepend_keymap and append_keymap. Prepend inserts before the default keybindings, while append inserts after them.

Prepend : inserts before the default keybindings.

append  : inserts after default.

A. Add bookmark(default bookmark)

can use 3rd-pary bokmar plugin. Read below secsion C.

## sample.
## "g" as prefix for bookmark.
## g >> y; go to yazi config dir.
  [[manager.prepend_keymap]]
  on   = [ "g", "y" ]
  run  = "cd ~/.config/yazi"
  desc = "cd ~/.config/yazi"

B. Add plugins and some useful tools.

Install plugins.

Read following page cafully.
I git clone plugin page inside ~/.config/yazi, but it is not corrcet...

## example. install maxpreview.

ya pack -a yazi-rs/plugins:max-preview
Some of my favorite plugins & useful tools.
## T : hide preview window.
 [[manager.prepend_keymap]]
 on   = "T"
 run  = "plugin toggle-pane min-preview"
 desc = "Show or hide the preview pane"

## cont-t :ax-preview window.
 [[manager.prepend_keymap]]
 on   = "<C-t>"
 run  = "plugin toggle-pane max-preview"
 desc = "Maximize or restore the preview pane"

## ! : open shell
 [[manager.prepend_keymap]]
 on   = "!"
 run  = 'shell "$SHELL" --block'
 desc = "Open shell here"

## ecape : use as "close". 
 [[input.prepend_keymap]]
 on   = "<Esc>"
 run  = "close"
 desc = "Cancel input"

## l (エル not 1) : open file.
 [[manager.prepend_keymap]]
 on   = "l"
 run  = "plugin smart-enter"
 desc = "Enter the child directory, or open the file"

## bookamark
## create its own bookmarks; bookmarkcache inside plugin-dir.
## https://gitee.com/DreamMaoMao/bookmarks.yazi
## "u" as prefix
[[manager.prepend_keymap]]
on = [ "u", "a" ]
run = "plugin bookmarks 'save'"
desc = "Save current position as a bookmark"

[[manager.prepend_keymap]]
on = [ "u", "g" ]
run = "plugin bookmarks  'jump'"
desc = "Jump to a bookmark"

[[manager.prepend_keymap]]
on = [ "u", "d" ]
run = "plugin bookmarks 'delete'"
desc = "Delete a bookmark"

[[manager.prepend_keymap]]
on = [ "u", "D" ]
run = "plugin bookmarks 'delete_all'"
desc = "Delete all bookmarks"

[[manager.prepend_keymap]]
on = [ "u", "m" ]
run = "plugin bookmarks 'modify'"
desc = "modify key bind to hoverd path"

C. Some comment about bookmark plugins.

  • git clone following page.
git clone https://github.com/DreamMaoMao/bookmarks.yazi.git ~/.config/yazi/plugins/bookmarks.yazi
  • should modify original bookmak plugin's setting.
    Maybe the original setting is old, and "--args" option is deprecated now.
[[manager.prepend_keymap]]
on = [ "u", "a" ]
- run = "plugin bookmarks --args='save'"  ## del --args
+  run = "plugin bookmarks 'save'"
desc = "Save current position as a bookmark"
  • contents of bookmarkcache inside plugins.
    Seems to be able to modify this file usig editor.
## sample
## u >> y ; go to yazi config dir.
y###/home/wan/.config/yazi/yazi.toml/###yazi###false
c###/home/wan/.config/###config###true
  • bookmark menu (hover)
    4-bookmark-hovor.jpg

D. Sample of plugin's effects.

default view
3-2_plugin_hide_pr-0.jpg

hida preview
3-2_plugin_hide_pr-1.jpg

max-preview
3-2_plugin_max_pr-1.jpg

Yazi show remote PC's image file(right-side) cleary on terminal, after ssh log-in.

3-2_plugin-pr-remotePC-2.jpg

4. Some useful functions.

4-1. search using fd, rg.

type "s" : fd file or directory search

5-search_fd-2.jpg

type "S" : rg contents saerch

5-search_rg-2.jpg

4-2. task manager

type "w" : show up task manager

then,
return : show each task content

or
type "x" : cancel task ## but can not cancel copy on my env.  why?

escape : close window

task manager window (hover)

5-rask_manager.jpg

5. key bindings.

nice reference page.
Find keys for copy, pastey, etc on this page.

Reference

  • Quick start

  • key bindings

  • yazi/git

  • yazi/ plugins

  • lots of 3rd party plugins?, but not official.

  • Qiita articles

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?