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

View File

@@ -1,3 +1,5 @@
--- @since 25.2.7
local selected_or_hovered = ya.sync(function()
local tab, paths = cx.active, {}
for _, u in pairs(tab.selected) do

View File

@@ -1,3 +1,5 @@
--- @since 25.2.7
local function setup(_, opts)
local type = opts and opts.type or ui.Border.ROUNDED
local old_build = Tab.build

View File

@@ -1,7 +1,7 @@
# git.yazi
> [!NOTE]
> Yazi v0.4.1 or later is required for this plugin to work.
> Yazi v25.2.7 or later is required for this plugin to work.
Show the status of Git file changes as linemode in the file list.

View File

@@ -1,3 +1,5 @@
--- @since 25.2.7
local WIN = ya.target_family() == "windows"
local PATS = {
{ "[MT]", 6 }, -- Modified
@@ -159,9 +161,6 @@ local function fetch(_, job)
local repo = root(cwd)
if not repo then
remove(tostring(cwd))
if not ya.__250127 then -- TODO: remove this
return 1
end
return true
end
@@ -178,10 +177,6 @@ local function fetch(_, job)
:stdout(Command.PIPED)
:output()
if not output then
if not ya.__250127 then -- TODO: remove this
ya.err("Cannot spawn git command, error: " .. err)
return 0
end
return true, Err("Cannot spawn `git` command, error: %s", err)
end
@@ -208,9 +203,6 @@ local function fetch(_, job)
end
add(tostring(cwd), repo, changed)
if not ya.__250127 then -- TODO: remove this
return 3
end
return false
end

View File

@@ -19,7 +19,7 @@ Make sure you have [glow](https://github.com/charmbracelet/glow) installed, and
## Feature
+ You can modify line wrap in `init.lua`, the current value is 55.
+ You can modify line wrap in `main.lua`, the current value is 55.
+ You can press `ctrl+e` to scroll up and `ctrl+y` to scroll down the readme file in preview panel in yazi: (add this to `keymap.toml`)
```toml
prepend_keymap = [

View File

@@ -1,7 +1,7 @@
local M = {}
function M:peek(job)
-- Set a fixed width of 55 characters for the preview
-- Set a fixed width of 50 characters for the preview
local preview_width = 55
local child = Command("glow")
@@ -55,20 +55,8 @@ function M:seek(job)
if not h or h.url ~= job.file.url then
return
end
local scroll_amount = 1
local scroll_offset = job.units
if job.key == "ctrl-e" then
scroll_offset = scroll_amount
elseif job.key == "ctrl-y" then
scroll_offset = -scroll_amount
else
scroll_offset = job.units
end
ya.manager_emit('peek', {
math.max(0, cx.active.preview.skip + scroll_offset),
math.max(0, cx.active.preview.skip + job.units),
only_if = job.file.url,
})
end

View File

@@ -1,57 +1,76 @@
local M = {}
function M:peek(job)
local child
local l = self.file.cha.len
if l == 0 then
child = Command("hexyl")
:args({
tostring(job.file.url),
})
:stdout(Command.PIPED)
:stderr(Command.PIPED)
:spawn()
else
child = Command("hexyl")
:args({
"--border",
"none",
"--terminal-width",
tostring(job.area.w),
tostring(job.file.url),
})
:stdout(Command.PIPED)
:stderr(Command.PIPED)
:spawn()
end
local child
local l = job.file.cha.len
if l == 0 then
child = Command("hexyl")
:args({
tostring(job.file.url),
})
:stdout(Command.PIPED)
:stderr(Command.PIPED)
:spawn()
else
child = Command("hexyl")
:args({
"--border", "none",
"--terminal-width", tostring(job.area.w),
tostring(job.file.url),
})
:stdout(Command.PIPED)
:stderr(Command.PIPED)
:spawn()
end
local limit = job.area.h
local i, lines = 0, ""
repeat
local next, event = child:read_line()
if event == 1 then
ya.err(tostring(event))
elseif event ~= 0 then
break
end
if not child then
return require("code").peek(job)
end
i = i + 1
if i > job.skip then
lines = lines .. next
end
until i >= job.skip + limit
local limit = job.area.h
local i, lines = 0, ""
repeat
local line, event = child:read_line()
if event == 1 then
ya.err(tostring(event))
break
elseif event ~= 0 then
break
end
child:start_kill()
if job.skip > 0 and i < job.skip + limit then
ya.manager_emit("peek", { math.max(0, i - limit), only_if = job.file.url, upper_bound = true })
else
lines = lines:gsub("\t", string.rep(" ", PREVIEW.tab_size))
ya.preview_widgets(job, { ui.Text.parse(lines):area(job.area) })
end
i = i + 1
if i > job.skip then
lines = lines .. line
end
until i >= job.skip + limit
child:start_kill()
if job.skip > 0 and i < job.skip + limit then
ya.manager_emit("peek", {
math.max(0, i - limit),
only_if = job.file.url,
upper_bound = true,
})
else
lines = lines:gsub("\t", string.rep(" ", PREVIEW.tab_size))
ya.preview_widgets(job, { ui.Text.parse(lines):area(job.area) })
end
end
function M:seek(units)
require("code").seek(job, units)
function M:seek(job)
-- Get the currently hovered file from your UI context.
local h = cx.active.current.hovered
if not h or h.url ~= job.file.url then
return
end
local scroll_offset = job.units
-- Emit a new peek event with the updated skip value.
ya.manager_emit("peek", {
math.max(0, cx.active.preview.skip + scroll_offset),
only_if = job.file.url,
})
end
return M

View File

@@ -1,5 +1,8 @@
# hide-preview.yazi
> [!WARNING]
> This plugin has been deprecated. Please use the new [toggle-pane.yazi](../toggle-pane.yazi) instead.
Switch the preview pane between hidden and shown.
https://github.com/yazi-rs/plugins/assets/17523360/c4f0b5c4-ff9f-4be8-ba73-4d8e7902e383

View File

@@ -1,6 +1,14 @@
--- @since 25.2.7
--- @sync entry
local function entry(st)
ya.notify {
title = "Deprecated plugin",
content = "The `hide-preview` plugin is deprecated, please use the new `toggle-pane` plugin instead: https://github.com/yazi-rs/plugins/tree/main/toggle-pane.yazi",
timeout = 10,
level = "warn",
}
if st.old then
Tab.layout, st.old = st.old, nil
else

View File

@@ -1,5 +1,8 @@
# max-preview.yazi
> [!WARNING]
> This plugin has been deprecated. Please use the new [toggle-pane.yazi](../toggle-pane.yazi) instead.
Maximize or restore the preview pane.
https://github.com/yazi-rs/plugins/assets/17523360/8976308e-ebfe-4e9e-babe-153eb1f87d61

View File

@@ -1,6 +1,14 @@
--- @since 25.2.7
--- @sync entry
local function entry(st)
ya.notify {
title = "Deprecated plugin",
content = "The `max-preview` plugin is deprecated, please use the new `toggle-pane` plugin instead: https://github.com/yazi-rs/plugins/tree/main/toggle-pane.yazi",
timeout = 10,
level = "warn",
}
if st.old then
Tab.layout, st.old = st.old, nil
else

View File

@@ -10,7 +10,7 @@
## Installation
If you use latest Yazi from main branch
If you use Yazi from latest main branch
```bash
# Linux/macOS
git clone https://github.com/ndtoan96/ouch.yazi.git ~/.config/yazi/plugins/ouch.yazi
@@ -22,16 +22,16 @@ git clone https://github.com/ndtoan96/ouch.yazi.git %AppData%\yazi\config\plugin
git clone https://github.com/ndtoan96/ouch.yazi.git "$($env:APPDATA)\yazi\config\plugins\ouch.yazi"
```
If you use Yazi <= 0.3.3
If you use Yazi < 0.4.3
```bash
# Linux/macOS
git clone --branch v0.2.1 --single-branch https://github.com/ndtoan96/ouch.yazi.git ~/.config/yazi/plugins/ouch.yazi
git clone --branch v0.4.0 --single-branch https://github.com/ndtoan96/ouch.yazi.git ~/.config/yazi/plugins/ouch.yazi
# Windows with cmd
git clone --branch v0.2.1 --single-branch https://github.com/ndtoan96/ouch.yazi.git %AppData%\yazi\config\plugins\ouch.yazi
git clone --branch v0.4.0 --single-branch https://github.com/ndtoan96/ouch.yazi.git %AppData%\yazi\config\plugins\ouch.yazi
# Windows with powershell
git clone --branch v0.2.1 --single-branch https://github.com/ndtoan96/ouch.yazi.git "$($env:APPDATA)\yazi\config\plugins\ouch.yazi"
git clone --branch v0.4.0 --single-branch https://github.com/ndtoan96/ouch.yazi.git "$($env:APPDATA)\yazi\config\plugins\ouch.yazi"
```
Make sure you have [ouch](https://github.com/ouch-org/ouch) installed and in your `PATH`.

View File

@@ -6,26 +6,14 @@ https://github.com/dedukun/relative-motions.yazi/assets/25795432/04fb186a-5efe-4
## Requirements
- [Yazi](https://github.com/sxyazi/yazi) v0.3.0+
- [Yazi](https://github.com/sxyazi/yazi) v25.2.7+
## Installation
If you use the latest Yazi from main branch
```sh
ya pack -a dedukun/relative-motions
```
If you are using <= v0.3.3
```sh
# Linux/macOS
git clone --branch 0.3.3 https://github.com/dedukun/relative-motions.yazi.git ~/.config/yazi/plugins/relative-motions.yazi
# Windows
git clone --branch 0.3.3 https://github.com/dedukun/relative-motions.yazi.git %AppData%\yazi\config\plugins\relative-motions.yazi
```
## Configuration
If you want to use the numbers directly to start a motion add this to your `keymap.toml`:
@@ -35,47 +23,47 @@ If you want to use the numbers directly to start a motion add this to your `keym
```toml
[[manager.prepend_keymap]]
on = [ "1" ]
run = "plugin relative-motions --args=1"
run = "plugin relative-motions 1"
desc = "Move in relative steps"
[[manager.prepend_keymap]]
on = [ "2" ]
run = "plugin relative-motions --args=2"
run = "plugin relative-motions 2"
desc = "Move in relative steps"
[[manager.prepend_keymap]]
on = [ "3" ]
run = "plugin relative-motions --args=3"
run = "plugin relative-motions 3"
desc = "Move in relative steps"
[[manager.prepend_keymap]]
on = [ "4" ]
run = "plugin relative-motions --args=4"
run = "plugin relative-motions 4"
desc = "Move in relative steps"
[[manager.prepend_keymap]]
on = [ "5" ]
run = "plugin relative-motions --args=5"
run = "plugin relative-motions 5"
desc = "Move in relative steps"
[[manager.prepend_keymap]]
on = [ "6" ]
run = "plugin relative-motions --args=6"
run = "plugin relative-motions 6"
desc = "Move in relative steps"
[[manager.prepend_keymap]]
on = [ "7" ]
run = "plugin relative-motions --args=7"
run = "plugin relative-motions 7"
desc = "Move in relative steps"
[[manager.prepend_keymap]]
on = [ "8" ]
run = "plugin relative-motions --args=8"
run = "plugin relative-motions 8"
desc = "Move in relative steps"
[[manager.prepend_keymap]]
on = [ "9" ]
run = "plugin relative-motions --args=9"
run = "plugin relative-motions 9"
desc = "Move in relative steps"
```
@@ -94,18 +82,19 @@ desc = "Trigger a new relative motion"
Additionally there are a couple of initial configurations that can be given to the plugin's `setup` function:
| Configuration | Values | Default | Description |
| -------------- | ----------------------------------------------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| `show_numbers` | `relative`, `absolute`, `relative_absolute` or `none` | `none` | Shows relative or absolute numbers before the file icon |
| `show_motion` | `true` or `false` | `false` | Shows current motion in Status bar |
| `only_motions` | `true` or `false` | `false` | If true, only the motion movements will be enabled, i.e., the commands for delete, cut, yank and visual selection will be disabled |
| Configuration | Values | Default | Description |
| -------------- | ----------------------------------------------------- | ---------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| `show_numbers` | `relative`, `absolute`, `relative_absolute` or `none` | `none` | Shows relative or absolute numbers before the file icon |
| `show_motion` | `true` or `false` | `false` | Shows current motion in Status bar |
| `only_motions` | `true` or `false` | `false` | If true, only the motion movements will be enabled, i.e., the commands for delete, cut, yank and visual selection will be disabled |
| `enter_mode` | `cache`, `first` or `cache_or_first` | `cache_or_first` | The method to enter folders |
If you want, for example, to enable relative numbers as well as to show the motion in the status bar,
add the following to Yazi's `init.lua`, i.e. `~/.config/yazi/init.lua`:
```lua
-- ~/.config/yazi/init.lua
require("relative-motions"):setup({ show_numbers="relative", show_motion = true })
require("relative-motions"):setup({ show_numbers="relative", show_motion = true, enter_mode ="first" })
```
> [!NOTE]
@@ -119,13 +108,15 @@ require("relative-motions"):setup({ show_numbers="relative", show_motion = true
This plugin adds the some basic vim motions like `3k`, `12j`, `10gg`, etc.
The following table show all the available motions:
| Command | Description |
| -------------- | ------------------- |
| `j`/`<Down>` | Move `n` lines down |
| `k`/`<Up>` | Move `n` lines up |
| `gj`/`g<Down>` | Go `n` lines down |
| `gk`/`g<Up>` | Go `n` lines up |
| `gg` | Go to line |
| Command | Description |
| -------------- | --------------------- |
| `j`/`<Down>` | Move `n` lines down |
| `k`/`<Up>` | Move `n` lines up |
| `h`/`<Left>` | Move `n` folders back |
| `l`/`<Right>` | Enter `n` folders |
| `gj`/`g<Down>` | Go `n` lines down |
| `gk`/`g<Up>` | Go `n` lines up |
| `gg` | Go to line |
Furthermore, the following operations were also added:

View File

@@ -1,3 +1,4 @@
--- @since 25.2.7
-- stylua: ignore
local MOTIONS_AND_OP_KEYS = {
{ on = "0" }, { on = "1" }, { on = "2" }, { on = "3" }, { on = "4" },
@@ -8,7 +9,7 @@ local MOTIONS_AND_OP_KEYS = {
{ on = "t" }, { on = "L" }, { on = "H" }, { on = "w" },
{ on = "W" }, { on = "<" }, { on = ">" }, { on = "~" },
-- movement
{ on = "g" }, { on = "j" }, { on = "k" }, { on = "<Down>" }, { on = "<Up>" }
{ on = "g" }, { on = "j" }, { on = "k" }, { on = "h" }, { on = "l" }, { on = "<Down>" }, { on = "<Up>" }, { on = "<Left>" }, { on = "<Right>" }
}
-- stylua: ignore
@@ -16,7 +17,7 @@ local MOTION_KEYS = {
{ on = "0" }, { on = "1" }, { on = "2" }, { on = "3" }, { on = "4" },
{ on = "5" }, { on = "6" }, { on = "7" }, { on = "8" }, { on = "9" },
-- movement
{ on = "g" }, { on = "j" }, { on = "k" }
{ on = "g" }, { on = "j" }, { on = "k" }, { on = "h" }, { on = "l" }, { on = "<Down>" }, { on = "<Up>" }, { on = "<Left>" }, { on = "<Right>" }
}
-- stylua: ignore
@@ -30,6 +31,10 @@ local SHOW_NUMBERS_ABSOLUTE = 0
local SHOW_NUMBERS_RELATIVE = 1
local SHOW_NUMBERS_RELATIVE_ABSOLUTE = 2
local ENTER_MODE_FIRST = 0
local ENTER_MODE_CACHE = 1
local ENTER_MODE_CACHE_OR_FIRST = 2
-----------------------------------------------
----------------- R E N D E R -----------------
-----------------------------------------------
@@ -149,6 +154,10 @@ local function normal_direction(dir)
return "j"
elseif dir == "<Up>" then
return "k"
elseif dir == "<Left>" then
return "h"
elseif dir == "<Right>" then
return "l"
end
return dir
end
@@ -205,6 +214,29 @@ end
local get_active_tab = ya.sync(function(_) return cx.tabs.idx end)
local get_cache_or_first_dir = ya.sync(function(state)
if state._enter_mode == ENTER_MODE_CACHE then
return nil
elseif state._enter_mode == ENTER_MODE_CACHE_OR_FIRST then
local hovered_file = cx.active.current.hovered
if hovered_file ~= nil and hovered_file.cha.is_dir then
return cx.active.current.cursor
end
end
local files = cx.active.current.files
local index = 1
for i = 1, #files do
if files[i].cha.is_dir then
index = i
break
end
end
return index - 1
end)
-----------------------------------------------
---------- E N T R Y / S E T U P ----------
-----------------------------------------------
@@ -231,7 +263,7 @@ return {
if cmd == "g" then
if direction == "g" then
ya.manager_emit("arrow", { -99999999 })
ya.manager_emit("arrow", { "top" })
ya.manager_emit("arrow", { lines - 1 })
render_clear()
return
@@ -254,6 +286,19 @@ return {
ya.manager_emit("arrow", { lines })
elseif cmd == "k" then
ya.manager_emit("arrow", { -lines })
elseif cmd == "h" then
for _ = 1, lines do
ya.manager_emit("leave", {})
end
elseif cmd == "l" then
for _ = 1, lines do
ya.manager_emit("enter", {})
local file_idx = get_cache_or_first_dir()
if file_idx then
ya.manager_emit("arrow", { "top" })
ya.manager_emit("arrow", { file_idx })
end
end
elseif is_tab_command(cmd) then
if cmd == "t" then
for _ = 1, lines do
@@ -315,6 +360,16 @@ return {
render_motion_setup()
end
if args["enter_mode"] == "cache" then
state._enter_mode = ENTER_MODE_CACHE
elseif args["enter_mode"] == "first" then
state._enter_mode = ENTER_MODE_FIRST
elseif args["enter_mode"] == "cache_or_first" then
state._enter_mode = ENTER_MODE_CACHE_OR_FIRST
else
state._enter_mode = ENTER_MODE_CACHE_OR_FIRST
end
if args["show_numbers"] == "absolute" then
render_numbers(SHOW_NUMBERS_ABSOLUTE)
elseif args["show_numbers"] == "relative" then

View File

@@ -1,6 +1,6 @@
# torrent-preview.yazi
[Yazi](https://github.com/sxyazi/yazi) plugin to preview `application/x-bittorrent` files
[Yazi](https://github.com/sxyazi/yazi) plugin to preview `application/bittorrent` files
![show case](https://github.com/kirasok/torrent-preview.yazi/assets/75790517/6f215e6d-bb19-46f4-b606-9241594028ff)
@@ -13,6 +13,14 @@
### Linux/MacOS
Using the [Yazi Package Manager](https://yazi-rs.github.io/docs/cli/#package-manager):
```sh
ya pack -a kirasok/torrent-preview
```
Or manually:
```sh
git clone https://github.com/kirasok/torrent-preview.yazi.git ~/.config/yazi/plugins/torrent-preview.yazi
```
@@ -23,6 +31,10 @@ Add this to your `yazi.toml`:
```toml
[[plugin.prepend_previewers]]
mime = "application/x-bittorrent"
mime = "application/bittorrent"
run = "torrent-preview"
```
> [!NOTE]
> Yazi after `v0.4` removes `x-` prefix from subtype, so even if `file -i` outputs `application/x-bittorrent`, you should use `application/bittorrent` ([relevant issue](https://github.com/kirasok/torrent-preview.yazi/issues/2))