67 KiB
augment-command.yazi
A Yazi plugin that enhances Yazi's default commands. This plugin is inspired by the Yazi tips page, the bypass.yazi plugin and the fast-enter.yazi plugin.
Table of Contents
- Requirements
- Installation
- Configuration
- What about the commands are augmented?
- Augmented commands
- New commands
- Usage
- Licence
Requirements
- Yazi v25.4.8+
7zor7zzcommandfilecommand
Optional dependencies
tarcommand for thepreserve_file_permissionsoption
Installation
# Add the plugin
ya pack -a hankertrix/augment-command
# Install plugin
ya pack -i
# Update plugin
ya pack -u
Configuration
| Configuration | Values | Default | Description |
|---|---|---|---|
prompt |
true or false |
false |
Create a prompt to choose between hovered and selected items when both exist. If this option is disabled, selected items will only be operated on when the hovered item is selected, otherwise the hovered item will be the default item that is operated on. |
default_item_group_for_prompt |
hovered, selected or none |
hovered |
The default item group to operate on when the prompt is submitted without any value. This only takes effect if prompt is set to true, otherwise this option doesn't do anything. hovered means the hovered item is operated on, selected means the selected items are operated on, and none just cancels the operation. |
smart_enter |
true or false |
true |
Use one command to open files or enter a directory. With this option set, the enter and open commands will both call the enter command when a directory is hovered and call the open command when a regular file is hovered. You can also enable this behaviour by passing the --smart flag to the enter or open commands. |
smart_paste |
true or false |
false |
Paste items into a directory without entering it. The behaviour is exactly the same as the smart paste tip on Yazi's documentation. Setting this option to false will use the default paste behaviour. You can also enable this behaviour by passing the --smart flag to the paste command. |
smart_tab_create |
true or false |
false |
Create tabs in the directory that is being hovered instead of the current directory. The behaviour is exactly the same as the smart tab tip on Yazi's documentation. Setting this option to false will use the default tab_create behaviour, which means you need to pass the --current flag to the command. You can also enable this behaviour by passing the --smart flag to the tab_create command. |
smart_tab_switch |
true or false |
false |
If the tab that is being switched to does not exist yet, setting this option to true will create all the tabs in between the current number of open tabs, and the tab that is being switched to. The behaviour is exactly the same as the smart switch tip on Yazi's documentation. Setting this option to false will use the default tab_switch behaviour. You can also enable this behaviour by passing the --smart flag to the tab_switch command. |
confirm_on_quit |
true or false |
true |
Setting this option to true will cause Yazi to prompt you for a confirmation before quitting when there is more than 1 tab open. Setting this option to false will use the default quit behaviour, which is to immediately quit Yazi. You can also enable this behaviour by passing the --confirm flag to the quit command. |
open_file_after_creation |
true or false |
false |
This option determines whether the plugin will open a file after it has been created. Setting this option to true will cause the plugin to open the created file. You can also enable this behaviour by passing the --open flag to the create command. |
enter_directory_after_creation |
true or false |
false |
This option determines whether the plugin will enter a directory after it has been created. Setting this option to true will cause the plugin to enter the created directory. You can also enable this behaviour by passing the --enter flag to the create command. |
use_default_create_behaviour |
true or false |
false |
This option determines whether the plugin will use the behaviour of Yazi's create command. Setting this option to true will use the behaviour of Yazi's create command. You can also enable this behaviour by passing the --default-behaviour flag to the create command. |
enter_archives |
true or false |
true |
Automatically extract and enter archive files. This option requires the 7z or 7zz command to be present. |
extract_retries |
An integer, like 1, 3, 10, etc. |
3 |
This option determines how many times the plugin will retry opening an encrypted or password-protected archive when a wrong password is given. This value plus 1 is the total number of times the plugin will try opening an encrypted or password-protected archive. |
recursively_extract_archives |
true or false |
true |
This option determines whether the plugin will extract all archives inside an archive file recursively. If this option is set to false, archive files inside an archive will not be extracted, and you will have to manually extract them yourself. |
preserve_file_permissions |
true or false |
false |
This option determines whether to preserve the file permissions of the items in the extracted archive. Setting this option to true will preserve the file permissions of the extracted items. It requires the tar command and will only work on tar archives, or tarballs, as 7z does not support preserving file permissions. You will receive a warning if you have this option set but tar is not installed. Do note that there are significant security implications of setting this option to true, as any executable file or binary in an archive can be immediately executed after it is extracted, which can compromise your system if you extract a malicious archive. As such, the default value is false, and it is strongly recommended to leave it as such. |
encrypt_archives |
true or false |
false |
This option determines whether the plugin will encrypt the archives it creates. If this option is set to true, the plugin will prompt for the archive password when creating an archive to encrypt it with. The plugin will prompt twice for the password, and will check both of them to see if they match. If they do, the password entered is set as the archive password. Otherwise, the plugin will show an error stating the passwords do not match, and prompt for two passwords again. Cancelling either of the prompts will cancel the whole process. |
encrypt_archive_headers |
true or false |
false |
This option determines whether the plugin will encrypt the headers of the archives it creates. If this option is set to true, the plugin will encrypt the headers of all 7z archives, which means the file list cannot be previewed and Yazi will not be able to preview the contents of the archive. This encryption is only available to 7z archives, so the plugin will show a warning message when this option is used, but the selected archive file type, does not support header encryption, like a zip archive, but will continue with the creation of the encrypted archive. This option has no effect when the archive is not encrypted, which is when encrypt_archives is set to false. |
reveal_created_archive |
true or false |
true |
This option determines whether the plugin will automatically hover over the created archive once created. |
remove_archived_files |
true or false |
false |
This option determines whether the plugin will automatically remove the files that were added to the created archive. |
must_have_hovered_item |
true or false |
true |
This option stops the plugin from executing any commands when there is no hovered item. |
skip_single_subdirectory_on_enter |
true or false |
true |
Skip directories when there is only one subdirectory and no other files when entering directories. This behaviour can be turned off by passing the --no-skip flag to the enter or open commands. |
skip_single_subdirectory_on_leave |
true or false |
true |
Skip directories when there is only one subdirectory and no other files when leaving directories. This behaviour can be turned off by passing the --no-skip flag to the leave command. |
smooth_scrolling |
true or false |
false |
Self-explanatory, this option enables smooth scrolling. |
scroll_delay |
A floating point number, like 0.02, 0.05, 0.1, etc. |
0.02 |
The delay, in seconds, between each call of the arrow command to scroll through the file list. The smaller the scroll_delay, the faster the file list is scrolled. Avoid setting a scroll_delay that is more than 1 second. This is due to the plugin being asynchronous, which will result in the plugin continuing to call the arrow command even when the directory has changed, or when you are in a different application that doesn't block Yazi, resulting in unexpected behaviour. |
wraparound_file_navigation |
true or false |
true |
Wrap around from the bottom to the top or from the top to the bottom when using the arrow or parent_arrow command to navigate. |
If you would like to use the default configuration, which is shown below,
you don't need to add anything to your ~/.config/yazi/init.lua
file on Linux and macOS, or your %AppData%\yazi\config\init.lua
file on Windows.
-- ~/.config/yazi/init.lua for Linux and macOS
-- %AppData%\yazi\config\init.lua for Windows
-- Using the default configuration
require("augment-command"):setup({
prompt = false,
default_item_group_for_prompt = "hovered",
smart_enter = true,
smart_paste = false,
smart_tab_create = false,
smart_tab_switch = false,
confirm_on_quit = true,
open_file_after_creation = false,
enter_directory_after_creation = false,
use_default_create_behaviour = false,
enter_archives = true,
extract_retries = 3,
recursively_extract_archives = true,
preserve_file_permissions = false,
encrypt_archives = false,
encrypt_archive_headers = false,
reveal_created_archive = true,
remove_archived_files = false,
must_have_hovered_item = true,
skip_single_subdirectory_on_enter = true,
skip_single_subdirectory_on_leave = true,
smooth_scrolling = false,
scroll_delay = 0.02,
wraparound_file_navigation = true,
})
However, if you would like to configure the plugin, you can add
your desired configuration options to your ~/.config/yazi/init.lua file
on Linux and macOS, or your
%AppData%\yazi\config\init.lua file on Windows.
You can leave out configuration options that you would
like to be left as default.
An example configuration is shown below:
-- ~/.config/yazi/init.lua for Linux and macOS
-- %AppData%\yazi\config\init.lua for Windows
-- Custom configuration
require("augment-command"):setup({
prompt = true,
default_item_group_for_prompt = "none",
open_file_after_creation = true,
enter_directory_after_creation = true,
extract_retries = 5,
encrypt_archives = true,
smooth_scrolling = true,
wraparound_file_navigation = false,
})
What about the commands are augmented?
All commands that can operate on multiple files and directories,
like open, rename, remove and shell,
as well as the new commands extract, archive,
editor and pager,
now determine an item group to operate on.
By default, the command will operate on the hovered item,
unless the hovered item is also selected,
then it will operate on the selected items.
- When
must_have_hovered_itemis set totrue, having no hovered item means the plugin will cancel the operation. - When
must_have_hovered_itemis set tofalseand there are selected items, the selected items will be operated on. - With
promptis set totrue, the plugin will always prompt you to choose an item group when there are both selected items and a hovered item.
Augmented commands
Open (open)
-
The
opencommand is augmented as stated in this section above.Videos:
-
When
promptis set totrue: -
When
promptis set tofalse:
-
-
When
smart_enteris set totrue, it calls theentercommand when the hovered item is a directory. -
--smartflag to use one command toopenfiles andenterdirectories. This flag will cause theopencommand to call theentercommand when the hovered item is a directory even whensmart_enteris set tofalse. This allows you to set a key to use this behaviour with theopencommand instead of using it for everyopencommand.Video:
-
--no-skipflag, which only applies whensmart_enteris used as it is passed to theentercommand. More details about this flag can be found at the documentation for the enter command. -
Automatically extracts and enters archive files, with support for skipping directories that contain only one subdirectory in the extracted archive. This can be disabled by setting
enter_archivestofalsein the configuration. This feature requires the7zor7zzcommand to be present to extract the archives.Video:
-
The
opencommand makes use of theextractcommand, so recursively extracting archives is also supported. For more information, look at the section about theextractcommand.Video:
Extract (extract)
-
Technically this is a new command, as Yazi does not provide an
extractcommand. However, Yazi does provide a built-in plugin calledextract, so this command is included in the augmented commands section instead of the new commands section. -
This command requires the
7zor7zzcommand to be present to extract the archives, as well as thefilecommand to check if a file is an archive or not. -
You are not meant to use this command directly. However, you can do so if you like, as the extract command is also augmented as stated in this section above.
Videos:
-
When
must_have_hovered_itemistrue: -
When
must_have_hovered_itemisfalse: -
When
promptis set totrue: -
When
promptis set tofalse:
-
-
Instead, this command is intended to replace the built-in
extractplugin, which is used for theextractopener. This way, you can use the features that come with the augmentedextractcommand, like recursively extracting archives, with theopencommand. This is the intended way to use this command, as theopencommand is meant to be the command that opens everything, so it is a bit counterintuitive to have to use a separate key to extract archives.To replace the built-in
extractplugin, copy theextractopeners section in Yazi's defaultyazi.tomlinto youryazi.toml, which is located at~/.config/yazi/yazi.tomlfor Linux and macOS, and%AppData%\yazi\config\yazi.tomlfile on Windows. Make sure that theextractopeners are under theopenerkey in youryazi.toml. Then replaceextractwithaugmented-extract, and you will be using the plugin'sextractcommand instead of Yazi's built-inextractplugin.Here is an example configuration:
# ~/.config/yazi/yazi.toml for Linux and macOS # %AppData%\yazi\config\yazi.toml for Windows [opener] extract = [ { run = 'ya pub augmented-extract --list "$@"', desc = "Extract here", for = "unix" }, { run = 'ya pub augmented-extract --list %*', desc = "Extract here", for = "windows" }, ]If that exceeds your editor's line length limit, another way to do it is:
# ~/.config/yazi/yazi.toml for Linux and macOS # %AppData%\yazi\config\yazi.toml for Windows [[opener.extract]] run = 'ya pub augmented-extract --list "$@"' desc = "Extract here" for = "unix" [[opener.extract]] run = 'ya pub augmented-extract --list %*' desc = "Extract here" for = "windows" -
The
extractcommand supports recursively extracting archives, which means if the extracted archive file contains other archive files in it, those archives will be automatically extracted, keeping the directory structure of the archive if the archive doesn't only contain a single archive file. This feature requires thefilecommand to detect the mime type of the extracted file, and to check whether it is an archive file or not. This makes extracting binaries from compressed tarballs much easier, as there's no need to press a key twice to decompress and extract the compressed tarballs. You can disable this feature by settingrecursively_extract_archivestofalsein the configuration.Video:
-
The
extractcommand also supports extracting encrypted archives, and will prompt you for a password when it encounters an encrypted archive. You can configure the number of times the plugin prompts you for a password by setting theextract_retriesconfiguration option. The default value is3, which means the plugin will prompt you3more times for the correct password after the initial password attempt before giving up and showing an error.Video:
-
The
preserve_file_permissionsconfiguration option applies to theextractcommand, and requires thetarcommand to be present, as7zdoes not support preserving file permissions. The plugin will show a warning if thepreserve_file_permissionsoption is set totruebuttaris not installed.For macOS users, it is highly recommended to install and use GNU
tar, orgtarinstead of the Apple providedtarcommand. You can install it using thebrewcommand below:brew install gnu-tarThe plugin will automatically use GNU
tarif it finds thegtarcommand instead of the Apple providedtarcommand.Setting the
preserve_file_permissionsconfiguration option totruewill preserve the file permissions of the files contained in atararchive or tarball.This has considerable security implications, as executables extracted from all
tararchives can be immediately executed on your system, possibly compromising your system if you extract a malicioustararchive. Hence, this option is set tofalseby default, and should be left as such. This option is provided for your convenience, but do seriously consider if such convenience is worth the risk of extracting a malicioustararchive that executes malware on your system. -
--revealflag to automatically hover the files that have been extracted.Video:
-
--removeflag to automatically remove the archive after the files have been extracted.Video:
Enter (enter)
-
When
smart_enteris set totrue, it calls theopencommand when the hovered item is a file. -
--smartflag to use one command toenterdirectories andopenfiles. This flag will cause theentercommand to call theopencommand when the selected items or the hovered item is a file, even whensmart_enteris set tofalse. This allows you to set a key to use this behaviour with theentercommand instead of using it for everyentercommand.Video:
-
Automatically skips directories that contain only one subdirectory when entering directories. This can be turned off by setting
skip_single_subdirectory_on_entertofalsein the configuration.Video:
-
--no-skipflag. It stops the plugin from skipping directories that contain only one subdirectory when entering directories, even whenskip_single_subdirectory_on_enteris set totrue. This allows you to set a key to navigate into directories without skipping the directories that contain only one subdirectory.
Leave (leave)
-
Automatically skips directories that contain only one subdirectory when leaving directories. This can be turned off by setting
skip_single_subdirectory_on_leavetofalsein the configuration.Video:
-
--no-skipflag. It stops the plugin from skipping directories that contain only one subdirectory, even whenskip_single_subdirectory_on_leaveis set totrue. This allows you to set a key to navigate out of directories without skipping the directories that contain only one subdirectory.
Rename (rename)
-
The
renamecommand is augmented as stated in this section above.Videos:
-
When
must_have_hovered_itemistrue: -
When
must_have_hovered_itemisfalse: -
When
promptis set totrue: -
When
promptis set tofalse:
-
Remove (remove)
-
The
removecommand is augmented as stated in this section above.Videos:
-
When
must_have_hovered_itemistrue: -
When
must_have_hovered_itemisfalse: -
When
promptis set totrue: -
When
promptis set tofalse:
-
Create (create)
-
You should use Yazi's default
createcommand instead of this augmentedcreatecommand if you don't want the paths without file extensions to be created as directories by default, and you don't care about automatically opening and entering the created file and directory respectively. -
The
createcommand has a different behaviour from Yazi'screatecommand. When the path given to the command doesn't have a file extension, thecreatecommand will create a directory instead of a file, unlike Yazi'screatecommand. Other that this major difference, thecreatecommand functions identically to Yazi'screatecommand, which means that you can use a trailing/on Linux and macOS, or\on Windows to create a directory. It will also recursively create directories to ensure that the path given exists. It also supports all the options supported by Yazi'screatecommand, so you can pass them to the command and expect the same behaviour. -
The rationale for this behaviour is that creating a path without a file extension usually means you intend to create a directory instead of a file, as files usually have file extensions.
Video:
-
When
open_file_after_creationis set totrue, thecreatecommand willopenthe created file. This behaviour can also be enabled by passing the--openflag to thecreatecommand.Video:
Likewise, when
enter_directory_after_creationis set totrue, thecreatecommand willenterthe created directory. This behaviour can also be enabled by passing the--enterflag to thecreatecommand.Video:
create-and-enter-directories-video
To enable both behaviours with flags, just pass both the
--openflag and the--enterflag to thecreatecommand.Video:
-
If you would like to use the behaviour of Yazi's
createcommand, probably because you would like to automatically open and enter the created file and directory respectively, you can either setuse_default_create_behaviourtotrue, or pass the--default-behaviourflag to thecreatecommand.Video:
Shell (shell)
-
This command runs the shell command given with the augment stated in this section above. You should only use this command if you need the plugin to determine a suitable item group for the command to operate on. Otherwise, you should just use the default
shellcommand provided by Yazi.Videos:
-
When
must_have_hovered_itemistrue: -
When
must_have_hovered_itemisfalse: -
When
promptis set totrue: -
When
promptis set tofalse:
-
-
To use this command, the syntax is exactly the same as the default
shellcommand provided by Yazi. You just provide the command you want and provide any Yazi shell variable, which is documented here. The plugin will automatically replace the shell variable you give with the file paths for the item group before executing the command. -
There is no need to quote the shell variable on Linux and macOS, as it is expanded by the plugin instead of the shell, and the paths are already quoted using the
ya.quotefunction before execution, so quoting is entirely unnecessary and may result in unexpected behaviour. -
--exit-if-dirflag to stop the shell command given from executing if the item group consists only of directories. For example, if the item group is the hovered item, then the shell command will not be executed if the hovered item is a directory. If the item group is the selected items group, then the shell command will not be executed if all the selected items are directories. This behaviour comes from it being used in thepagercommand. Thepagercommand is essentially:# ~/.config/yazi/keymap.toml on Linux and macOS # %AppData%\yazi\config\keymap.toml on Windows [[manager.prepend_keymap]] on = "i" run = "plugin augment-command -- shell '$PAGER $@' --block --exit-if-dir" desc = "Open the pager"It is also used in the
editorcommand, since you usually wouldn't use your text editor to open directories, especially if you are already using a terminal file manager like Yazi. Theeditorcommand is essentially:# ~/.config/yazi/keymap.toml on Linux and macOS # %AppData%\yazi\config\keymap.toml on Windows [[manager.prepend_keymap]] on = "o" run = "plugin augment-command -- shell '$EDITOR $@' --block --exit-if-dir" desc = "Open the editor"Video:
Passing arguments to the shell command
Ideally, you will want to avoid using backslashes to escape the shell command arguments, so here are a few ways to do it:
-
Shell arguments that don't have special shell variables on Linux and macOS, like
$SHELL, or don't have special shell characters like>,|or spaces, need not be quoted with double quotes"or single quotes'respectively. For example:# ~/.config/yazi/keymap.toml on Linux and macOS # %AppData%\yazi\config\keymap.toml on Windows [[manager.prepend_keymap]] on = "i" run = "plugin augment-command -- shell --block 'bat -p --pager less $@'" desc = "Open with bat"Even though the
$@argument above is considered a shell variable in Linux and macOS, the plugin automatically replaces it with the full path of the items in the item group, so it does not need to be quoted with double quotes", as it is expanded by the plugin, and not meant to be expanded by the shell. -
If the arguments to the
shellcommand have special shell variables on Linux and macOS, like$SHELL, or special shell characters like>,|, or spaces, use--to denote the end of the flags and options passed to theshellcommand. For example:# ~/.config/yazi/keymap.toml on Linux and macOS # %AppData%\yazi\config\keymap.toml on Windows [[manager.prepend_keymap]] on = "<C-s>" run = 'plugin augment-command -- shell --block -- sh -c "$SHELL"' desc = "Open a shell inside of a shell here"# ~/.config/yazi/keymap.toml on Linux and macOS # %AppData%\yazi\config\keymap.toml on Windows [[manager.prepend_keymap]] on = "<C-s>" run = "plugin augment-command -- shell --block -- sh -c 'echo hello'" desc = "Open a shell and say hello inside the opened shell" -
If the arguments passed to the
shellcommand themselves contain arguments that have special shell variables on Linux and macOS, like$SHELL, or special shell characters like>,|, or spaces, use the triple single quote'''delimiter for therunstring.# ~/.config/yazi/keymap.toml on Linux and macOS # %AppData%\yazi\config\keymap.toml on Windows [[manager.prepend_keymap]] on = "<C-s>" run = '''plugin augment-command -- shell --block -- sh -c 'sh -c "$SHELL"'''' desc = "Open a shell inside of a shell inside of a shell here"# ~/.config/yazi/keymap.toml on Linux and macOS # %AppData%\yazi\config\keymap.toml on Windows [[manager.prepend_keymap]] on = "<C-s>" run = '''plugin augment-command -- shell --block -- sh -c "$SHELL -c 'echo hello'" ''' desc = "Open a shell inside of a shell and say hello inside the opened shell"A more legitimate use case for this would be something like Yazi's tip to email files using Mozilla Thunderbird:
# ~/.config/yazi/keymap.toml on Linux and macOS # %AppData%\yazi\config\keymap.toml on Windows [[manager.prepend_keymap]] on = "<C-e>" run = '''plugin augment-command -- shell -- paths=$(for p in $@; do echo "$p"; done | paste -s -d,) thunderbird -compose "attachment='$paths'" ''' desc = "Email files using Mozilla Thunderbird"Once again, the
$@variable above does not need to be quoted in double quotes"as it is expanded by the plugin instead of the shell.
If the above few methods to avoid using backslashes
within your shell command to escape the quotes are
still insufficient for your use case,
it is probably more appropriate to write a shell script
in a separate file and execute that instead of
writing the shell command inline
in your keymap.toml file.
Paste (paste)
-
When
smart_pasteis set totrue, thepastecommand will paste items into the hovered directory without entering it. If the hovered item is not a directory, the command pastes in the current directory instead. Otherwise, whensmart_pasteis set tofalse, thepastecommand will behave like the defaultpastecommand. -
--smartflag to enable pasting in the hovered directory without entering the directory. This flag will cause thepastecommand to paste items into the hovered directory even whensmart_pasteis set tofalse. This allows you to set a key to use this behaviour with thepastecommand instead of using it for everypastecommand.Video:
Tab create (tab_create)
-
When
smart_tab_createis set totrue, thetab_createcommand will create a tab in the hovered directory instead of the current directory like the default key binds. If the hovered item is not a directory, then the command just creates a new tab in the current directory instead. Otherwise, whensmart_tab_createis set tofalse, thetab_createcommand will behave like the default key bind to create a tab, which istab_create --current. -
--smartflag to enable creating a tab in the hovered directory. This flag will cause thetab_createcommand to create a tab in the hovered directory even whensmart_tab_createis set tofalse. This allows you to set a specific key to use this behaviour with thetab_createcommand instead of using it for everytab_createcommand.Video:
Tab switch (tab_switch)
-
When
smart_tab_switchis set totrue, thetab_switchcommand will ensure that the tab that is being switched to exist. It does this by automatically creating all the tabs required for the desired tab to exist. For example, if you are switching to tab 5 (tab_switch 4), and you only have two tabs currently open (tabs 1 and 2), the plugin will create tabs 3, 4 and 5 and then switch to tab 5. The tabs are created using the current directory. Thesmart_tab_createconfiguration option does not affect the behaviour of this command. Otherwise, whensmart_tab_switchis set tofalse, thetab_switchcommand will behave like the defaulttab_switchcommand, and simply switch to the tab if it exists, and do nothing if it doesn't exist. -
--smartflag to automatically create the required tabs for the desired tab to exist. This flag will cause thetab_switchcommand to automatically create the required tabs even whensmart_tab_switchis set tofalse. This allows you to set a specific key to use this behaviour with thetab_switchcommand instead of using it for everytab_switchcommand.Video:
Quit (quit)
-
You should use Yazi's default
quitcommand instead of this augmented command if you don't want to have a prompt when quitting Yazi with multiple tabs open. This command has a visual side effect of showing a confirmation prompt for a split second before closing Yazi when quitting Yazi with only 1 tab open, which can be annoying. This confirmation prompt is due to the plugin still running for a bit after thequitcommand is emitted, causing Yazi to prompt you for confirmation as there are tasks still running. However, once the plugin has stopped running, which is a split second after thequitcommand is emitted, Yazi will exit. You can observe this visual effect in the video demonstration below. -
When
confirm_on_quitis set totrue, the plugin will prompt you for confirmation when there is more than 1 tab open. Otherwise, it will immediately quit Yazi, just like the defaultquitcommand. -
--confirmflag to get the plugin to prompt you for confirmation when quitting with multiple tabs open. This flag will cause thequitcommand to prompt you for confirmation when quitting with multiple tabs open even whenconfirm_on_quitis set tofalse. This allows you to set a specific key to use this behaviour with thequitcommand instead of using it for everyquitcommand.Video:
Arrow (arrow)
-
When
smooth_scrollingis set totrue, the arrow command will smoothly scroll through the file list.Video:
-
When
wraparound_file_navigationis set totrue, the arrow command will wrap around from the bottom to the top or from the top to the bottom when navigating.Video:
-
When both
smooth_scrollingandwraparound_file_navigationare set totrue, the command will smoothly scroll the wraparound transition as well.Video:
-
Otherwise, it'll behave like the default
arrow 1command. -
--no-wrapflag to prevent thearrowcommand from wrapping around, even whenwraparound_file_navigationis set totrue.
New commands
Parent arrow (parent_arrow)
-
This command behaves like the
arrowcommand, but in the parent directory. It allows you to navigate in the parent directory without leaving the current directory.Video:
-
When
smooth_scrollingis set totrue, this command will smoothly scroll through the parent directories.Video:
-
When
wraparound_file_navigationis set totrue, this command will also wrap around from the bottom to the top or from top to the bottom when navigating in the parent directory.Video:
-
When both
smooth_scrollingandwraparound_file_navigationare set totrue, the command will smoothly scroll the wraparound transition as well.Video:
-
You can also replicate this using this series of commands below, but it doesn't work as well, and doesn't support wraparound navigation or smooth scrolling:
# ~/.config/yazi/keymap.toml on Linux and macOS # %AppData%\yazi\config\keymap.toml on Windows # Use K to move up in the parent directory [[manager.prepend_keymap]] on = "K" run = ["leave", "arrow -1", "enter"] desc = "Move up in the parent directory" # Use J to move down in the parent directory [[manager.prepend_keymap]] on = "J" run = ["leave", "arrow 1", "enter"] desc = "Move down in the parent directory" -
--no-wrapflag to prevent theparent_arrowcommand from wrapping around, even whenwraparound_file_navigationis set totrue.
Archive (archive)
-
The
archivecommand adds the selected or hovered items to an archive, with the plugin prompting for an archive name. The archive file extension given will be used to determine the type of archive to create. -
This command is also augmented as stated in this section above.
Videos:
-
When
must_have_hovered_itemistrue: -
When
must_have_hovered_itemisfalse: -
When
promptis set totrue: -
When
promptis set tofalse:
-
-
--encryptflag to encrypt the archive with the given password, which applies even whenencrypt_archivesis set tofalse. -
--encrypt-headersflag to encrypt the archive headers, which applies even whenencrypt_archive_headersis set tofalse. Note that this option only works with7zarchives, other types of archives likeziparchives do not support header encryption. The plugin will show a warning if the archive type does not support header encryption and the flag is passed, but will continue with the creation of the encrypted archive. This option has no effect if eitherencrypt_archivesis set tofalseor the--encryptflag isn't given.Video:
-
--revealflag to automatically hover the archive file that is created, which applies even whenreveal_created_archiveis set tofalse.Video:
-
--removeflag to automatically remove the files that are added to the archive, which applies even whenremove_archived_filesis set tofalse.Video:
Editor (editor)
-
The
editorcommand opens the default editor set by the$EDITORenvironment variable. -
The command is also augmented as stated in this section above.
Videos:
-
When
must_have_hovered_itemistrue: -
When
must_have_hovered_itemisfalse: -
When
promptis set totrue: -
When
promptis set tofalse:
-
Pager (pager)
-
The
pagercommand opens the default pager set by the$PAGERenvironment variable. -
The command is also augmented as stated in this section above.
-
The
pagercommand will also skip opening directories, as the pager cannot open directories and will error out. Hence, the command will not do anything when the hovered item is a directory, or if all the selected items are directories. This makes the pager command less annoying as it will not try to open a directory and then immediately fail with an error, causing a flash and causing Yazi to send a notification.Videos:
-
When
must_have_hovered_itemistrue: -
When
must_have_hovered_itemisfalse: -
When
promptis set totrue: -
When
promptis set tofalse:
-
Usage
Add the commands that you would like to use to your keymap.toml file,
located at ~/.config/yazi/keymap.toml on Linux and macOS
and at %AppData%\yazi\config\keymap.toml
on Windows, in this format:
# ~/.config/yazi/keymap.toml on Linux and macOS
# %AppData%\yazi\config\keymap.toml on Windows
[[manager.prepend_keymap]]
on = "key"
run = "plugin augment-command -- command arguments --flags --options=42"
desc = "Description"
For example, to use the augmented enter command:
# ~/.config/yazi/keymap.toml on Linux and macOS
# %AppData%\yazi\config\keymap.toml on Windows
[[manager.prepend_keymap]]
on = "l"
run = "plugin augment-command -- enter"
desc = "Enter a directory and skip directories with only a single subdirectory"
All the default arguments, flags and options provided by Yazi are also supported, for example:
# ~/.config/yazi/keymap.toml on Linux and macOS
# %AppData%\yazi\config\keymap.toml on Windows
[[manager.prepend_keymap]]
on = "k"
run = "plugin augment-command -- arrow -1"
desc = "Move cursor up"
[[manager.prepend_keymap]]
on = "r"
run = "plugin augment-command -- rename --cursor=before_ext"
desc = "Rename a file or directory"
[[manager.prepend_keymap]]
on = "D"
run = "plugin augment-command -- remove --permanently"
desc = "Permanently delete the files"
[[manager.prepend_keymap]]
on = ["g", "j"]
run = "plugin augment-command -- parent_arrow 1"
For the default descriptions of the commands, you can refer to
Yazi's default keymap.toml file.
Essentially, all you need to do to use this plugin
is to add plugin augment-command --, with a space at the end,
in front of a Yazi command, such as enter,
which results in plugin augment-command -- enter'.
Using the extract command as an opener
This is the intended way to use the extract command instead of binding
the extract command to a key in your keymap.toml file.
Look at the extract command section
for details on how to do so.
Full configuration example
For a full configuration example,
you can have a look at my keymap.toml file
and my yazi.toml file.
Licence
This plugin is licenced under the GNU AGPL v3 licence.
You can view the full licence in the LICENSE file.