keymap.toml
If you want to fine-tune the default settings, the first step is to create your own configuration file.
You can change Yazi's keybindings in your keymap.toml
file, which consists of the following 6 layers:
- [manager] - File list.
- [tasks] - Task manager.
- [spot] - File information spotter.
- [pick] - Pick component. e.g. "open with" for files.
- [input] - Input component. e.g. create, rename, etc.
- [completion] - Completion component. e.g. "cd" path completion.
- [help] - Help menu.
In each layer, there are two attributes: prepend_keymap
and append_keymap
.
Prepend inserts before the default keybindings, while append inserts after them.
Since Yazi selects the first matching key to run, prepend always has a higher priority than default, and append always has a lower priority than default:
[manager]
prepend_keymap = [
{ on = "<C-a>", run = 'my-fev-command1', desc = "Just for test!" },
]
append_keymap = [
{ on = [ "g", "a" ], run = 'my-fev-command2', desc = "Just for test!" },
]
Or in another different style:
[[manager.prepend_keymap]]
on = "<C-a>"
run = 'my-fev-command1'
desc = "Just for test!"
[[manager.prepend_keymap]]
on = [ "g", "a" ]
run = 'my-fev-command2'
[[manager.append_keymap]]
on = "c"
run = 'my-fev-command3'
But keep in mind that you can only choose one of them, and it cannot be a combination of the two, as TOML language does not allow this:
[manager]
prepend_keymap = [
{ on = "<C-a>", run = 'my-fev-command1', desc = "Just for test!" },
]
[[manager.prepend_keymap]]
on = [ "g", "a" ]
run = 'my-fev-command2'
desc = "Just for test!"
When you don't need any default and want to fully customize your keybindings, use keymap
, for example:
[manager]
keymap = [
# This will override all default keybindings, and just keep the two below.
{ on = "<C-a>", run = 'my-fev-command1', desc = "Just for test!" },
{ on = [ "g", "a" ], run = 'my-fev-command2', desc = "Just for test!" },
]
[manager]
escape
Cancel find, exit visual mode, clear selected, cancel filter, or cancel search.
Argument/Option | Description |
---|---|
--all | Do all the below. |
--find | Cancel find. |
--visual | Exit visual mode. |
--select | Clear selected. |
--filter | Cancel filter. |
--search | Cancel search. |
Automatically determine the operation by default, and it will only execute the selected operation after specifying the option; multiple options can be stacked.
quit
Exit the process.
Argument/Option | Description |
---|---|
--no-cwd-file | Don't output the current directory to the file specified by yazi --cwd-file . |
close
Close the current tab; if it's the last tab, exit the process instead.
suspend
Pauses Yazi and returns to the parent shell to continue with other tasks.
Once those tasks are done, use the fg
command of the shell to send a resume signal and return back to Yazi.
arrow
Argument/Option | Description |
---|---|
[n] / [n%] | Move the cursor up or down by n or n% lines. Use negative values to move up and positive values to move down. |
leave
Go back to the parent directory of the hovered file, or the parent of the current working directory if no file is hovered on.
enter
Enter the child directory.
back
Go back to the previous directory.
forward
Go forward to the next directory.
seek
Scroll the contents in the preview panel.
Argument/Option | Description |
---|---|
[n] | Use negative values to seek up and positive values to seek down. |
spot
Display file information with the preset or user-customized spotter.
cd
Change the current directory.
Argument/Option | Description |
---|---|
[path] | The path to change to. |
--interactive | Use an interactive UI to input the path. |
You can add your own g
series keys to achieve a simple bookmark feature:
[[manager.prepend_keymap]]
on = [ "g", "d" ]
run = "cd ~/Downloads"
desc = "Cd to ~/Downloads"
[[manager.prepend_keymap]]
on = [ "g", "p" ]
run = "cd ~/Pictures"
desc = "Cd to ~/Pictures"
For Windows users, you can also switch drives using the cd
command:
[[manager.prepend_keymap]]
on = [ "g", "d" ]
run = "cd D:"
desc = "Switch to D drive"
[[manager.prepend_keymap]]
on = [ "g", "p" ]
run = 'cd "E:\\Pictures"' # We need to escape the backslash
desc = 'Cd to E:\Pictures'
Check out the resources page for a more comprehensive bookmark plugin.
reveal
Change the current directory to the parent of specified file, and hover on it.
Argument/Option | Description |
---|---|
[path] | The path to reveal. |
toggle
Toggle the selection state of the hovered file.
Argument/Option | Description |
---|---|
N/A | Reverse the selection. |
--state=on | Select the file. |
--state=off | Deselect the file. |
toggle_all
Toggle the selection state of all files in the current working directory.
Argument/Option | Description |
---|---|
N/A | Reverse the selections. |
--state=on | Select the files. |
--state=off | Deselect the files. |
Note that toggle_all --state=off
only deselect the files in CWD, if you have selected files across multiple directories, and want to deselect all of them, use escape --select
.
visual_mode
Enter visual mode (selection mode).
Argument/Option | Description |
---|---|
--unset | Enter visual mode (unset mode). |
open
Open the selected files using the rules in [open]
.
Argument/Option | Description |
---|---|
--interactive | Open the hovered/selected file(s) with an interactive UI to choose the opening method. |
--hovered | Always open the hovered file regardless of the selection state. |
yank
Yank the selected files.
Argument/Option | Description |
---|---|
--cut | Cut the selected files. |
unyank
Cancel the yank status of files.
paste
Paste the yanked files.
Argument/Option | Description |
---|---|
--force | Overwrite the destination file if it exists. |
--follow | Copy the file pointed to by a symbolic link, rather than the link itself. Only can be used during copying. |
link
Create a symbolic link to the yanked files. (This is a privileged action on Windows and must be run as an administrator.)
Argument/Option | Description |
---|---|
--relative | Use a relative path for the symbolic link. |
--force | Overwrite the destination file if it exists. |
hardlink
Hardlink the yanked files.
Argument/Option | Description |
---|---|
--force | Overwrite the destination file if it exists. |
--follow | Hardlink the file pointed to by a symbolic link, not the symlink itself. |
remove
Move the files to the trash/recycle bin on macOS/Windows. For Linux, it will follow The FreeDesktop.org Trash specification.
In the Android platform, you can only use it with the --permanently
option, since there lacks the concept of a trash bin.
Argument/Option | Description |
---|---|
--force | Don't show the confirmation dialog, and trash/delete files directly. |
--permanently | Permanently delete the files. |
--hovered | Always remove the hovered file regardless of the selection state. |
create
Create a file or directory. Ends with /
(Unix) or \
(Windows) for directories.
Argument/Option | Description |
---|---|
--dir | Always create directories, regardless of whether end with / or \ . |
--force | Overwrite the destination file directly if it exists, without showing the confirmation dialog. |
rename
Rename a file or directory, or bulk rename if multiple files are selected ($EDITOR
is used to edit the filenames by default, see Specify a different editor for bulk renaming for details).
--hovered
: Always rename the hovered file regardless of the selection state.--force
: Overwrite the destination file directly if it exists, without showing the confirmation dialog.--empty
: Empty a part of the filename."stem"
: Empty the stem. e.g."foo.jpg"
->".jpg"
."ext"
: Empty the extension. e.g."foo.jpg"
->"foo."
."dot_ext"
: Empty the dot and extension. e.g."foo.jpg"
->"foo"
."all"
: Empty the whole filename. e.g."foo.jpg"
->""
.
--cursor
: Specify the cursor position of the renaming input box."end"
: The end of the filename."start"
: The start of the filename."before_ext"
: Before the extension of the filename.
You can also use --cursor
with --empty
, for example, rename --empty=stem --cursor=start
will empty the file's stem, and move the cursor to the start.
Which causes the input box content for the filename foo.jpg
to be |.jpg
, where "|" represents the cursor position.
copy
Copy the path of files or directories that are selected or hovered on.
Argument/Option | Description |
---|---|
path | Copy the absolute path. |
dirname | Copy the path of the parent directory. |
filename | Copy the name of the file. |
name_without_ext | Copy the name of the file without the extension. |
shell
Run a shell command.
Argument/Option | Description |
---|---|
[template] | Optional, command template to be run. |
--block | Open in a blocking manner. After setting this, Yazi will hide into a secondary screen and display the program on the main screen until it exits. During this time, it can receive I/O signals, which is useful for interactive programs. |
--orphan | Keep the process running even if Yazi has exited, once specified, the process will be detached from the task scheduling system. |
--interactive | Request the user to input the command to be run interactively |
--cursor | Set the initial position of the cursor in the interactive command input box. For example, shell 'zip -r .zip "$0"' --cursor=7 --interactive places the cursor before .zip . |
You can use the following shell variables in [run]
:
$n
(Unix) /%n
(Windows): The N-th selected file, starting from1
. e.g.$2
represents the second selected file.$@
(Unix) /%*
(Windows): All selected files, i.e.$1
,$2
, ...,$n
.$0
(Unix) /%0
(Windows): The hovered file.
hidden
Set the visibility of hidden files.
Argument/Option | Description |
---|---|
show | Show hidden files. |
hide | Hide hidden files. |
toggle | Default, toggle the hidden state. |
linemode
Set the line mode.
Argument/Option | Description |
---|---|
none | No line mode. |
size | Display the size in bytes of the file. Note that currently directory sizes are only evaluated when sort_by = "size" , and this might change in the future. |
btime | Display the birth time of the file. |
mtime | Display the last modified time of the file. |
permissions | Display the permissions of the file, only available on Unix-like systems. |
owner | Display the owner of the file, only available on Unix-like systems. |