Update 2025-02-24

Update 2025-02-03

Update 2025-02-04

Update 2025-02-09

Update 2025-02-14

Update 2025-02-15

Update 2025-02-22

Update 2025-02-24
This commit is contained in:
2025-02-02 16:12:25 +02:00
parent 73a0cc0977
commit 5f54bb78ad
69 changed files with 5418 additions and 2753 deletions

View File

@@ -2,7 +2,7 @@
A [Yazi][yazi-link] plugin that enhances Yazi's default commands.
This plugin is inspired by the
[Yazi tips page](https://yazi-rs.github.io/docs/tips),
[Yazi tips page][yazi-tips-page],
the [bypass.yazi](https://github.com/Rolv-Apneseth/bypass.yazi) plugin
and the [fast-enter.yazi](https://github.com/ourongxing/fast-enter.yazi)
plugin.
@@ -20,7 +20,7 @@ plugin.
## Requirements
- [Yazi](https://github.com/sxyazi/yazi) v0.4.2+
- [Yazi][yazi-link] v25.2.7+
- [`7z` or `7zz` command][7z-link]
- [`file` command][file-command-link]
@@ -51,6 +51,7 @@ ya pack -u
| `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][smart-paste-tip]. 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][smart-tab-tip]. 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][smart-switch-tip]. 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. |
@@ -65,13 +66,12 @@ ya pack -u
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
`C:\Users\USERNAME\AppData\Roaming\yazi\config\init.lua`
file on Windows, where `USERNAME` is your Windows username.
file on Linux and macOS, or your `%AppData%\yazi\config\init.lua`
file on Windows.
```lua
-- ~/.config/yazi/init.lua for Linux and macOS
-- C:\Users\USERNAME\AppData\Roaming\yazi\config\init.lua for Windows
-- %AppData%\yazi\config\init.lua for Windows
-- Using the default configuration
require("augment-command"):setup({
@@ -81,6 +81,7 @@ require("augment-command"):setup({
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,
@@ -98,15 +99,14 @@ require("augment-command"):setup({
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
`C:\Users\USERNAME\AppData\Roaming\yazi\config\init.lua`
file on Windows, where `USERNAME` is your Windows username.
`%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:
```lua
-- ~/.config/yazi/init.lua for Linux and macOS
-- C:\Users\USERNAME\AppData\Roaming\yazi\config\init.lua for Windows
-- %AppData%\yazi\config\init.lua for Windows
-- Custom configuration
require("augment-command"):setup({
@@ -238,8 +238,7 @@ then it will operate on the selected items.
[`extract` openers section][yazi-yazi-toml-extract-openers]
in [Yazi's default `yazi.toml`][yazi-yazi-toml] into your `yazi.toml`,
which is located at `~/.config/yazi/yazi.toml` for Linux and macOS, and
`C:\Users\USERNAME\AppData\Roaming\yazi\config\yazi.toml`
file on Windows, where `USERNAME` is your Windows username.
`%AppData%\yazi\config\yazi.toml` file on Windows.
Make sure that the `extract` openers are under the `opener` key in your
`yazi.toml`. Then replace `extract` with `augmented-extract`,
and you will be using the plugin's `extract` command instead of
@@ -249,7 +248,7 @@ then it will operate on the selected items.
```toml
# ~/.config/yazi/yazi.toml for Linux and macOS
# C:\Users\USERNAME\AppData\Roaming\yazi\config\yazi.toml for Windows
# %AppData%\yazi\config\yazi.toml for Windows
[opener]
extract = [
@@ -262,7 +261,7 @@ then it will operate on the selected items.
```toml
# ~/.config/yazi/yazi.toml for Linux and macOS
# C:\Users\USERNAME\AppData\Roaming\yazi\config\yazi.toml for Windows
# %AppData%\yazi\config\yazi.toml for Windows
[[opener.extract]]
run = 'ya pub augmented-extract --list "$@"'
@@ -452,16 +451,7 @@ then it will operate on the selected items.
create directories to ensure that the path given exists.
It also supports all the options supported by Yazi's `create` command,
so you can pass them to the command and expect the same behaviour.
However, due to the
[`confirm` component](https://github.com/sxyazi/yazi/issues/2082)
currently not being exposed to plugin developers, it uses Yazi's input
component to prompt for a confirmation, like in Yazi v0.3.0 and below.
This is not ideal, but it shouldn't happen that often and
hopefully wouldn't be too annoying.
If you are using the latest version of Yazi from the main branch,
the `confirm` component is now exposed to plugin developers and
the plugin will use the `confirm` component instead.
However, the separator in the `confirm` component will be the text colour
Do note that the separator in the `confirm` component will be the text colour
instead of your configured border colour for the `confirm` component as
the `list` part of the `confirm` component has not been exposed to plugin
developers, so the separator is made using text.
@@ -536,43 +526,15 @@ then it will operate on the selected items.
- To use this command, the syntax is exactly the same as the default
`shell` command provided by Yazi. You just provide the command you want and
provide any Yazi shell variable, which is documented
[here](https://yazi-rs.github.io/docs/configuration/keymap/#manager.shell).
[here][yazi-shell-variables].
The plugin will automatically replace the shell variable you give
with the file paths for the item group before executing the command.
- You will also need to escape the quotes when giving the shell command
if you use the same quotes to quote the given arguments to the plugin.
For example, if you pass the arguments to the plugin with double quotes,
i.e. `--args="shell"`, you will have to escape the double quotes with a
backslash character, like shown below:
```toml
# ~/.config/yazi/keymap.toml on Linux and macOS
# C:\Users\USERNAME\AppData\Roaming\yazi\config\keymap.toml on Windows
[[manager.prepend_keymap]]
on = [ "o" ]
run = 'plugin augment-command --args="shell \"$EDITOR $@\" --block"'
desc = "Open the editor"
```
- Alternatively, you can use the triple single quote `'''` delimiter
for the run string and avoid the escaping the shell command altogether,
like the two examples below:
```toml
# ~/.config/yazi/keymap.toml on Linux and macOS
# C:\Users\USERNAME\AppData\Roaming\yazi\config\keymap.toml on Windows
[[manager.prepend_keymap]]
on = [ "o" ]
run = '''plugin augment-command --args='shell "$EDITOR $@" --block''''
desc = "Open the editor"
[[manager.prepend_keymap]]
on = [ "i" ]
run = '''plugin augment-command --args="shell '$PAGER $@' --block"'''
desc = "Open the pager"
```
- 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.quote` function
before execution, so quoting is entirely unnecessary
and may result in unexpected behaviour.
- `--exit-if-dir` flag to stop the shell command given
from executing if the item group consists only of directories.
@@ -586,11 +548,11 @@ then it will operate on the selected items.
```toml
# ~/.config/yazi/keymap.toml on Linux and macOS
# C:\Users\USERNAME\AppData\Roaming\yazi\config\keymap.toml on Windows
# %AppData%\yazi\config\keymap.toml on Windows
[[manager.prepend_keymap]]
on = [ "i" ]
run = '''plugin augment-command --args="shell '$PAGER $@' --block --exit-if-dir"'''
on = "i"
run = "plugin augment-command -- shell '$PAGER $@' --block --exit-if-dir"
desc = "Open the pager"
```
@@ -601,18 +563,118 @@ then it will operate on the selected items.
```toml
# ~/.config/yazi/keymap.toml on Linux and macOS
# C:\Users\USERNAME\AppData\Roaming\yazi\config\keymap.toml on Windows
# %AppData%\yazi\config\keymap.toml on Windows
[[manager.prepend_keymap]]
on = [ "i" ]
run = '''plugin augment-command --args="shell '$EDITOR $@' --block --exit-if-dir"'''
desc = "Open the pager"
on = "o"
run = "plugin augment-command -- shell '$EDITOR $@' --block --exit-if-dir"
desc = "Open the editor"
```
Video:
[shell-exit-if-directory-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:
1. 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:
```toml
# ~/.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.
2. If the arguments to the `shell` command 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 the `shell` command.
For example:
```toml
# ~/.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"
```
```toml
# ~/.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"
```
3. If the arguments passed to the `shell` command 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 the `run` string.
```toml
# ~/.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"
```
```toml
# ~/.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][thunderbird-tip]:
```toml
# ~/.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_paste` is set to `true`,
@@ -699,6 +761,35 @@ then it will operate on the selected items.
[smart-tab-switch-video]
### Quit (`quit`)
- You should use Yazi's default `quit` command 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 the `quit` command 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 the `quit` command is emitted, Yazi will exit.
You can observe this visual effect in the video demonstration below.
- When `confirm_on_quit` is set to `true`, the plugin will prompt you for
confirmation when there is more than 1 tab open. Otherwise, it will
immediately quit Yazi, just like the default `quit` command.
- `--confirm` flag to get the plugin to prompt you for confirmation when
quitting with multiple tabs open.
This flag will cause the `quit` command to prompt you for confirmation
when quitting with multiple tabs open even when `confirm_on_quit` is
set to `false`.
This allows you to set a specific key to use this behaviour with the
`quit` command instead of using it for every `quit` command.
Video:
[quit-with-confirmation-video]
### Arrow (`arrow`)
- When `wraparound_file_navigation` is set to `true`,
@@ -738,19 +829,19 @@ then it will operate on the selected items.
```toml
# ~/.config/yazi/keymap.toml on Linux and macOS
# C:\Users\USERNAME\AppData\Roaming\yazi\config\keymap.toml on Windows
# %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" ]
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" ]
on = "J"
run = ["leave", "arrow 1", "enter"]
desc = "Move down in the parent directory"
```
@@ -815,16 +906,16 @@ then it will operate on the selected items.
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 `C:\Users\USERNAME\AppData\Roaming\yazi\config\keymap.toml`
and at `%AppData%\yazi\config\keymap.toml`
on Windows, in this format:
```toml
# ~/.config/yazi/keymap.toml on Linux and macOS
# C:\Users\USERNAME\AppData\Roaming\yazi\config\keymap.toml on Windows
# %AppData%\yazi\config\keymap.toml on Windows
[[manager.prepend_keymap]]
on = [ "key" ]
run = "plugin augment-command --args='command arguments --flags --options=42'"
on = "key"
run = "plugin augment-command -- command arguments --flags --options=42"
desc = "Description"
```
@@ -832,11 +923,11 @@ For example, to use the augmented `enter` command:
```toml
# ~/.config/yazi/keymap.toml on Linux and macOS
# C:\Users\USERNAME\AppData\Roaming\yazi\config\keymap.toml on Windows
# %AppData%\yazi\config\keymap.toml on Windows
[[manager.prepend_keymap]]
on = [ "l" ]
run = "plugin augment-command --args='enter'"
on = "l"
run = "plugin augment-command -- enter"
desc = "Enter a directory and skip directories with only a single subdirectory"
```
@@ -845,33 +936,35 @@ are also supported, for example:
```toml
# ~/.config/yazi/keymap.toml on Linux and macOS
# C:\Users\USERNAME\AppData\Roaming\yazi\config\keymap.toml on Windows
# %AppData%\yazi\config\keymap.toml on Windows
[[manager.prepend_keymap]]
on = [ "k" ]
run = "plugin augment-command --args='arrow -1'"
on = "k"
run = "plugin augment-command -- arrow -1"
desc = "Move cursor up"
[[manager.prepend_keymap]]
on = [ "r" ]
run = "plugin augment-command --args='rename --cursor=before_ext'"
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 --args='remove --permanently'"
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][yazi-keymap-toml].
Essentially, all you need to do to use this plugin
is to wrap a Yazi command in single quotes,
like `'enter'`,
then add `plugin augment-command --args=`
in front of it, which results in
`plugin augment-command --args='enter'`.
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
@@ -883,7 +976,7 @@ for details on how to do so.
### Full configuration example
For a full configuration example,
you can take a look at [my `keymap.toml` file][my-keymap-toml]
you can have a look at [my `keymap.toml` file][my-keymap-toml]
and [my `yazi.toml` file][my-yazi-toml].
## [Licence]
@@ -894,6 +987,7 @@ You can view the full licence in the [`LICENSE`][Licence] file.
<!-- Regular links -->
[yazi-link]: https://github.com/sxyazi/yazi
[yazi-tips-page]: https://yazi-rs.github.io/docs/tips
[smart-paste-tip]: https://yazi-rs.github.io/docs/tips#smart-paste
[smart-tab-tip]: https://yazi-rs.github.io/docs/tips#smart-tab
[smart-switch-tip]: https://yazi-rs.github.io/docs/tips#smart-switch
@@ -905,6 +999,8 @@ You can view the full licence in the [`LICENSE`][Licence] file.
[brew-link]: https://brew.sh/
[yazi-yazi-toml-extract-openers]: https://github.com/sxyazi/yazi/blob/main/yazi-config/preset/yazi-default.toml#L51-L54
[yazi-yazi-toml]: https://github.com/sxyazi/yazi/blob/main/yazi-config/preset/yazi-default.toml
[yazi-shell-variables]: https://yazi-rs.github.io/docs/configuration/keymap/#manager.shell
[thunderbird-tip]: https://yazi-rs.github.io/docs/tips#email-selected-files-using-thunderbird
[yazi-keymap-toml]: https://github.com/sxyazi/yazi/blob/main/yazi-config/preset/keymap-default.toml
[my-keymap-toml]: https://github.com/hankertrix/Dotfiles/blob/main/.config/yazi/keymap.toml
[my-yazi-toml]: https://github.com/hankertrix/Dotfiles/blob/main/.config/yazi/yazi.toml
@@ -979,6 +1075,10 @@ You can view the full licence in the [`LICENSE`][Licence] file.
[smart-tab-switch-video]: https://github.com/user-attachments/assets/1afb540d-47a9-4625-ae59-95d5cd91aa35
<!-- Quit command -->
[quit-with-confirmation-video]: https://github.com/user-attachments/assets/b6206ee4-766b-44ce-b90b-15b015ae71f9
<!-- Arrow command -->
[wraparound-arrow-video]: https://github.com/user-attachments/assets/41ea1fb0-a526-4549-95a2-547c3c4b0498

File diff suppressed because it is too large Load Diff