knowledge/technology/applications/cli/yazi.md

208 lines
112 KiB
Markdown
Raw Normal View History

2024-03-14 10:15:53 +00:00
---
obj: application
wesite: https://yazi-rs.github.io
repo: https://github.com/sxyazi/yazi
rev: 2024-03-14
---
# Yazi
Yazi (means "duck") is a terminal file manager written in [Rust](../../dev/programming/languages/Rust.md), based on non-blocking async I/O. It aims to provide an efficient, user-friendly, and customizable file management experience.
## Features
- 🚀 Full Asynchronous Support: All I/O operations are asynchronous, CPU tasks are spread across multiple threads, making the most of available resources.
- 💪 Powerful Async Task Scheduling and Management: Provides real-time progress updates, task cancellation, and internal task priority assignment.
- 🖼️ Built-in Support for Multiple Image Protocols: Also integrated with Überzug++, covering almost all terminals.
- 🌟 Built-in Code Highlighting and Image Decoding: Combined with the pre-loading mechanism, greatly accelerates image and normal file loading.
- 🔌 Concurrent Plugin System: UI plugins (rewriting most of the UI), functional plugins, custom previewer, and custom preloader; Just some pieces of Lua.
- 🧰 Integration with [fd](fd.md), [rg](ripgrep.md), fzf, zoxide
- 💫 Vim-like input/select/notify component, auto-completion for cd paths
- 🏷️ Multi-Tab Support, Cross-directory selection, Scrollable Preview (for videos, PDFs, archives, directories, code, etc.)
- 🔄 Bulk Renaming, Visual Mode, File Chooser
- 🎨 Theme System, Custom Layouts, Trash Bin, CSI u
- ... and more!
![Screenshot][Screenshot]
## Dependencies
To use Yazi, you must have the following prerequisites installed:
- [`file`](system/file.md) (for file type detection)
Yazi can be optionally extended with other command line tools to enable additional features.
- `nerd-fonts` (recommended)
- `ffmpegthumbnailer` (for video thumbnails)
- `unar` (for archive preview)
- [`jq`](jq.md) (for [JSON](../../files/JSON.md) preview)
- `poppler` (for [PDF](../../files/PDF.md) preview)
- [`fd`](fd.md) (for file searching)
- [`rg`](ripgrep.md) (for file content searching)
- `fzf` (for quick file subtree navigation)
- `zoxide` (for historical directories navigation)
## Shell Wrapper
We suggest using this ya [shell](Shell.md) wrapper that provides the ability to change the current working directory when exiting Yazi.
```shell
function ya() {
local tmp="$(mktemp -t "yazi-cwd.XXXXX")"
yazi "$@" --cwd-file="$tmp"
if cwd="$(cat -- "$tmp")" && [ -n "$cwd" ] && [ "$cwd" != "$PWD" ]; then
cd -- "$cwd"
fi
rm -f -- "$tmp"
}
```
## Keybindings
### Navigation
To navigate between files and directories you can use the arrow keys `←`, `↑`, `↓` and `→` or Vim-like commands 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 commands can be found in the table below.
| Key binding | Action |
| ----------- | ---------------------------- |
| `K` | Move the cursor up 5 lines |
| `J` | Move the cursor down 5 lines |
| `g``g` | Move cursor to the top |
| `G` | Move cursor to the bottom |
### Selection
To select files and directories, the following commands 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/directory operations
To interact with selected files/directories use any of the commands below.
| Key binding | Action |
| -------------- | --------------------------------------------------------------------------- |
| `o` | Open the selected files |
| `O` | Open the selected files interactively |
| `<Enter>` | Open the selected files |
| `<Ctrl-Enter>` | Open the selected files interactively (some terminals don't support it yet) |
| `y` | Yank the selected files (copy) |
| `x` | Yank the selected files (cut) |
| `p` | Paste the yanked files |
| `P` | Paste the yanked files (overwrite if the destination exists) |
| `-` | Create a symbolic link to the yanked files (absolute path) |
| `_` | Create a symbolic link to the yanked files (relative path) |
| `d` | Move the files to the trash |
| `D` | Permanently delete the files |
| `a` | Create a file or directory (ends with "/" for directories) |
| `r` | Rename a file or directory |
| `;` | Run a [shell](Shell.md) command |
| `:` | Run a [shell](Shell.md) command (block the UI until the command finishes) |
| `.` | Toggle the visibility of hidden files |
| `<Ctrl-s>` | Cancel the ongoing search |
| `z` | Jump to a directory using zoxide |
| `Z` | Jump to a directory, or reveal a file using fzf |
| `w` | Show task manager |
### Copying paths
To copy paths, use any of the following commands below.
> _Observation: `c ⇒ d` indicates pressing the `c` key followed by pressing the `d` key._
| Key binding | Action |
| ----------- | ----------------------------------------------- |
| `c``c` | Copy absolute path |
| `c``d` | Copy the path of the parent directory |
| `c``f` | Copy the name of the file |
| `c``n` | Copy the name of the file without the extension |
### Filtering files/directories
| Key binding | Action |
| ----------- | ----------------------------------- |
| `f` | Filter the files/directories in CWD |
### Finding files/directories
| Key binding | Action |
| ----------- | ----------------------------------- |
| `/` | Forward find file/directory in CWD |
| `?` | Backward find file/directory in CWD |
| `n` | Jump to next occurrence |
| `N` | Jump to previous occurrence |
### Searching files/directories
| Key binding | Action |
| ----------- | ------------------------------------------------------------------------------ |
| `s` | Search files by name using [fd](https://github.com/sharkdp/fd) |
| `S` | Search files by content using [ripgrep](https://github.com/BurntSushi/ripgrep) |
### Sorting
To sort files/directories use the following commands.
> _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) |
| `,``c` | Sort by creation time |
| `,``C` | Sort by creation 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) |
### Line Mode
You can change the output of the line mode with the following commands:
| Key binding | Action |
| ----------- | --------------------------- |
| `ms` | Set linemode to size |
| `mp` | Set linemode to permissions |
| `mm` | Set linemode to mtime |
| `mn` | Set linemode to none |
### Changing directories
You can quickly change directories with these commands:
| Key binding | Action |
| ------------- | ------------------------------- |
| `gh` | Go to the home directory |
| `gc` | Go to the config directory |
| `gd` | Go to the downloads directory |
| `gt` | Go to the temporary directory |
| `g + <Space>` | Go to a directory interactively |
### Tabs
You can use tabs with the following commands:
| Key binding | Action |
| ----------- | ------------------------------------------ |
| `<Ctrl-q>` | Close current tab |
| `t` | Create a new tab using current path |
| `1-9` | Switch to tab with number |
| `[` | Switch to the previous tab |
| `]` | Switch to the next tab |
| `{` | Swap the current tab with the previous tab |
| `}` | Swap the current tab with the next tab |
## Configuration
There are three configuration files for Yazi:
- `yazi.toml` - General configuration.
- `keymap.toml` - Keybindings configuration.
- `theme.toml` - Color scheme configuration.
You can find the default configuration files at https://github.com/sxyazi/yazi/tree/latest/yazi-config/preset.
You can change the Yazi configuration directory by exporting the `YAZI_CONFIG_HOME` environment variable.
[Screenshot]: data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUEAAAD5bWV0YQAAAAAAAAAvaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAFBpY3R1cmVIYW5kbGVyAAAAAA5waXRtAAAAAAABAAAAHmlsb2MAAAAARAAAAQABAAAAAQAAASEAAS34AAAAKGlpbmYAAAAAAAEAAAAaaW5mZQIAAAAAAQAAYXYwMUNvbG9yAAAAAGppcHJwAAAAS2lwY28AAAAUaXNwZQAAAAAAAAMgAAACWgAAABBwaXhpAAAAAAMICAgAAAAMYXYxQ4EkAAAAAAATY29scm5jbHgAAgACAACAAAAAF2lwbWEAAAAAAAAAAQABBAECgwQAAS4AbWRhdAoOIAAAJM4/LL//NAQ0AIAy5NsEEACQAByCR4rDPPPCFqfDDNNdd13VQJywRPn/yqnd+FiF+T0Le5KHbsMVWdWnmvu8R8xUlL6K5tmKEnPQPOprdD40U6+DfnX8q1uf3dP71Fds0d2IoW4Z+5/qeTi7u+1i4cbBu+AncRi3+mQrN1cZ1GOX3WVbaYGOQ8aeo6HoqszSWsrLfQeZI2ihqq9v6jIlVPb2vK58Y4cV3wXeA/hJJZLk6XkZ3y1nQM+HGCt4VQxKA295m3Bux5xQetZTezX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