mirror of
https://github.com/kristoferssolo/solorice.git
synced 2025-10-21 20:10:34 +00:00
Update: 2024-10-17
This commit is contained in:
parent
eae6ecaebb
commit
e2c877478c
0
config/HybridBar/scripts/change-active-workspace
Executable file → Normal file
0
config/HybridBar/scripts/change-active-workspace
Executable file → Normal file
0
config/HybridBar/scripts/get-active-workspace
Executable file → Normal file
0
config/HybridBar/scripts/get-active-workspace
Executable file → Normal file
0
config/HybridBar/scripts/get-window-title
Executable file → Normal file
0
config/HybridBar/scripts/get-window-title
Executable file → Normal file
0
config/HybridBar/scripts/get-workspaces
Executable file → Normal file
0
config/HybridBar/scripts/get-workspaces
Executable file → Normal file
0
config/eww/scripts/change-active-workspace
Executable file → Normal file
0
config/eww/scripts/change-active-workspace
Executable file → Normal file
0
config/eww/scripts/get-active-workspace
Executable file → Normal file
0
config/eww/scripts/get-active-workspace
Executable file → Normal file
0
config/eww/scripts/get-music
Executable file → Normal file
0
config/eww/scripts/get-music
Executable file → Normal file
0
config/eww/scripts/get-network
Executable file → Normal file
0
config/eww/scripts/get-network
Executable file → Normal file
0
config/eww/scripts/get-window-title
Executable file → Normal file
0
config/eww/scripts/get-window-title
Executable file → Normal file
0
config/eww/scripts/get-workspaces
Executable file → Normal file
0
config/eww/scripts/get-workspaces
Executable file → Normal file
0
config/eww/scripts/getvol
Executable file → Normal file
0
config/eww/scripts/getvol
Executable file → Normal file
0
config/eww/scripts/github
Executable file → Normal file
0
config/eww/scripts/github
Executable file → Normal file
0
config/lf/cleaner
Executable file → Normal file
0
config/lf/cleaner
Executable file → Normal file
0
config/lf/lfrc
Executable file → Normal file
0
config/lf/lfrc
Executable file → Normal file
0
config/nsxiv/exec/image-info
Executable file → Normal file
0
config/nsxiv/exec/image-info
Executable file → Normal file
0
config/nsxiv/exec/key-handler
Executable file → Normal file
0
config/nsxiv/exec/key-handler
Executable file → Normal file
0
config/nsxiv/exec/nsxiv-url
Executable file → Normal file
0
config/nsxiv/exec/nsxiv-url
Executable file → Normal file
0
config/nsxiv/exec/thumb-info
Executable file → Normal file
0
config/nsxiv/exec/thumb-info
Executable file → Normal file
0
config/nsxiv/exec/win-title
Executable file → Normal file
0
config/nsxiv/exec/win-title
Executable file → Normal file
0
config/x11/opt-apps
Executable file → Normal file
0
config/x11/opt-apps
Executable file → Normal file
@ -1,4 +1,4 @@
|
||||
-- require("relative-motions"):setup({ show_numbers = "relative", show_motion = true })
|
||||
require("relative-motions"):setup({ show_numbers = "relative", show_motion = true })
|
||||
require("full-border"):setup()
|
||||
require("starship"):setup()
|
||||
require("augment-command"):setup({
|
||||
@ -14,3 +14,4 @@ require("augment-command"):setup({
|
||||
ignore_hidden_items = false,
|
||||
wraparound_file_navigation = false,
|
||||
})
|
||||
require("git"):setup()
|
||||
|
||||
@ -45,11 +45,11 @@ keymap = [
|
||||
{on = [ "G" ], run = "arrow 99999999", desc = "Move cursor to the bottom"},
|
||||
|
||||
# Selection
|
||||
{on = [ "<Space>" ], run = [ "select --state=none", "arrow 1" ], desc = "Toggle the current selection state"},
|
||||
{on = [ "<Space>" ], run = [ "toggle --state=none", "arrow 1" ], desc = "Toggle the current selection state"},
|
||||
{on = [ "v" ], run = "visual_mode", desc = "Enter visual mode (selection mode)"},
|
||||
{on = [ "V" ], run = "visual_mode --unset", desc = "Enter visual mode (unset mode)"},
|
||||
{on = [ "<C-a>" ], run = "select_all --state=true", desc = "Select all files"},
|
||||
{on = [ "<C-r>" ], run = "select_all --state=none", desc = "Inverse selection of all files"},
|
||||
{on = [ "<C-a>" ], run = "toggle_all --state=true", desc = "Select all files"},
|
||||
{on = [ "<C-r>" ], run = "toggle_all --state=none", desc = "Inverse selection of all files"},
|
||||
|
||||
# Operation
|
||||
{on = [ "e" ], run = "open", desc = "Open the selected files"},
|
||||
@ -159,11 +159,12 @@ prepend_keymap = [
|
||||
# chmod
|
||||
{on = [ "c", "m" ], run = "plugin chmod", desc = "Chmod on selected files"},
|
||||
# Archive
|
||||
{on = [ "c", "a" ], run = "plugin archive", desc = "Archive selected files"},
|
||||
{on = [ "c", "a" ], run = "plugin ouch --args=zip", desc = "Compress with ouch"},
|
||||
# Augment Command
|
||||
{on = [ "l" ], run = "plugin augment-command --args='enter'", desc = "Enter a directory and skip directories with only a single subdirectory"},
|
||||
{on = [ "k" ], run = "plugin augment-command --args='arrow -1'", desc = "Move cursor up"},
|
||||
{on = [ "r" ], run = "plugin augment-command --args='rename --cursor=before_ext'", desc = "Rename a file or directory"},
|
||||
{on = [ "R" ], run = "plugin augment-command --args='rename'", desc = "Rename a file or directory"},
|
||||
{on = [ "D" ], run = "plugin augment-command --args='remove --permanently'", desc = "Permanently delete the files"},
|
||||
# Dragon
|
||||
{on = [ "m", "a" ], run = ''' shell 'ripdrag -atk "$@"' --confirm ''', desc = "Drag and drop all"},
|
||||
@ -175,15 +176,16 @@ prepend_keymap = [
|
||||
# Hide Preview
|
||||
{on = "<C-t>", run = "plugin --sync hide-preview", desc = "Hide or show preview"},
|
||||
# Relative motions
|
||||
# {on = [ "1" ], run = "plugin relative-motions --args=1", desc = "Move in relative steps"},
|
||||
# {on = [ "2" ], run = "plugin relative-motions --args=2", desc = "Move in relative steps"},
|
||||
# {on = [ "3" ], run = "plugin relative-motions --args=3", desc = "Move in relative steps"},
|
||||
# {on = [ "4" ], run = "plugin relative-motions --args=4", desc = "Move in relative steps"},
|
||||
# {on = [ "5" ], run = "plugin relative-motions --args=5", desc = "Move in relative steps"},
|
||||
# {on = [ "6" ], run = "plugin relative-motions --args=6", desc = "Move in relative steps"},
|
||||
# {on = [ "7" ], run = "plugin relative-motions --args=7", desc = "Move in relative steps"},
|
||||
# {on = [ "8" ], run = "plugin relative-motions --args=8", desc = "Move in relative steps"},
|
||||
# {on = [ "9" ], run = "plugin relative-motions --args=9", desc = "Move in relative steps"},
|
||||
{on = [ "1" ], run = "plugin relative-motions --args=1", desc = "Move in relative steps"},
|
||||
{on = [ "2" ], run = "plugin relative-motions --args=2", desc = "Move in relative steps"},
|
||||
{on = [ "3" ], run = "plugin relative-motions --args=3", desc = "Move in relative steps"},
|
||||
{on = [ "4" ], run = "plugin relative-motions --args=4", desc = "Move in relative steps"},
|
||||
{on = [ "5" ], run = "plugin relative-motions --args=5", desc = "Move in relative steps"},
|
||||
{on = [ "6" ], run = "plugin relative-motions --args=6", desc = "Move in relative steps"},
|
||||
{on = [ "7" ], run = "plugin relative-motions --args=7", desc = "Move in relative steps"},
|
||||
{on = [ "8" ], run = "plugin relative-motions --args=8", desc = "Move in relative steps"},
|
||||
{on = [ "9" ], run = "plugin relative-motions --args=9", desc = "Move in relative steps"},
|
||||
{on = [ "c", "s" ], run = "plugin what-size", desc = "Calc size of selection or cwd"},
|
||||
]
|
||||
|
||||
[tasks]
|
||||
|
||||
@ -1,20 +1,22 @@
|
||||
[plugin]
|
||||
deps = [
|
||||
{use = "AnirudhG07/nbpreview", commit = "f0149a4"},
|
||||
{use = "kirasok/torrent-preview", commit = "76970b6"},
|
||||
{use = "Sonico98/exifaudio", commit = "92366cf"},
|
||||
{use = "Reledia/miller", commit = "75f0002"},
|
||||
{use = "Reledia/glow", commit = "536185a"},
|
||||
{use = "yazi-rs/plugins#chmod", commit = "3783ea0"},
|
||||
{use = "yazi-rs/plugins#full-border", commit = "3783ea0"},
|
||||
{use = "KKV9/archive", commit = "9f3b049"},
|
||||
{use = "Rolv-Apneseth/starship", commit = "6197e4c"},
|
||||
{use = "Reledia/hexyl", commit = "64daf93"},
|
||||
{use = "hankertrix/augment-command", commit = "d81ddb8"},
|
||||
{use = "imsi32/yatline", commit = "d26ffbc"},
|
||||
{use = "dedukun/relative-motions", commit = "a5465c0"},
|
||||
{use = "yazi-rs/plugins#max-preview", commit = "3783ea0"},
|
||||
{use = "yazi-rs/plugins#hide-preview", commit = "3783ea0"},
|
||||
{use = "AnirudhG07/nbpreview", rev = "52a14b3"},
|
||||
{use = "Reledia/glow", rev = "d8b36ff"},
|
||||
{use = "Reledia/hexyl", rev = "ccc0a4a"},
|
||||
{use = "Reledia/miller", rev = "40e0265"},
|
||||
{use = "Rolv-Apneseth/starship", rev = "77a65f5"},
|
||||
{use = "Sonico98/exifaudio", rev = "d75db46"},
|
||||
{use = "dedukun/relative-motions", rev = "6aecfcd"},
|
||||
{use = "hankertrix/augment-command", rev = "b0f113d"},
|
||||
{use = "imsi32/yatline", rev = "7b56434"},
|
||||
{use = "kirasok/torrent-preview", rev = "76970b6"},
|
||||
{use = "ndtoan96/ouch", rev = "251da69"},
|
||||
{use = "pirafrank/what-size", rev = "f08f7f2"},
|
||||
{use = "yazi-rs/plugins:chmod", rev = "4f1d0ae"},
|
||||
{use = "yazi-rs/plugins:full-border", rev = "4f1d0ae"},
|
||||
{use = "yazi-rs/plugins:git", rev = "4f1d0ae"},
|
||||
{use = "yazi-rs/plugins:hide-preview", rev = "4f1d0ae"},
|
||||
{use = "yazi-rs/plugins:max-preview", rev = "4f1d0ae"},
|
||||
]
|
||||
|
||||
[flavor]
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
# archive.yazi
|
||||
# ~~archive.yazi~~ compress.yazi
|
||||
|
||||
A Yazi plugin that compresses selected files to an archive.
|
||||
A Yazi plugin that compresses selected files to an archive. Supporting yazi versions 0.2.5 and up.
|
||||
|
||||
## Supported file types
|
||||
|
||||
@ -10,8 +10,9 @@ A Yazi plugin that compresses selected files to an archive.
|
||||
| .7z | 7z a | 7z a |
|
||||
| .tar | tar rpf | tar rpf |
|
||||
| .tar.gz | gzip | 7z a -tgzip |
|
||||
| .tar.bz2 | bzip2 | 7z a -tbzip2 |
|
||||
| .tar.xz | xz | 7z a -txz |
|
||||
| .tar.bz2 | bzip2 | 7z a -tbzip2 |
|
||||
| .tar.zst | zstd | zstd |
|
||||
|
||||
|
||||
**NOTE:** Windows users are required to install 7-Zip and add 7z.exe to the `path` environment variable, only tar archives will be available otherwise.
|
||||
@ -21,13 +22,13 @@ A Yazi plugin that compresses selected files to an archive.
|
||||
|
||||
```bash
|
||||
# For Unix platforms
|
||||
git clone https://github.com/KKV9/archive.yazi.git ~/.config/yazi/plugins/archive.yazi
|
||||
git clone https://github.com/KKV9/compress.yazi.git ~/.config/yazi/plugins/compress.yazi
|
||||
|
||||
## For Windows
|
||||
git clone https://github.com/KKV9/archive.yazi.git %AppData%\yazi\config\plugins\archive.yazi
|
||||
git clone https://github.com/KKV9/compress.yazi.git %AppData%\yazi\config\plugins\compress.yazi
|
||||
|
||||
# Or with yazi plugin manager
|
||||
ya pack -a KKV9/archive
|
||||
ya pack -a KKV9/compress
|
||||
```
|
||||
|
||||
- Add this to your `keymap.toml`:
|
||||
@ -35,7 +36,7 @@ ya pack -a KKV9/archive
|
||||
```toml
|
||||
[[manager.prepend_keymap]]
|
||||
on = [ "c", "a" ]
|
||||
run = "plugin archive"
|
||||
run = "plugin compress"
|
||||
desc = "Archive selected files"
|
||||
```
|
||||
|
||||
|
||||
@ -9,7 +9,7 @@ local function notify_error(message, urgency)
|
||||
end
|
||||
|
||||
-- Check for windows
|
||||
local is_windows = package.config:sub(1, 1) == "\\"
|
||||
local is_windows = ya.target_family() == "windows"
|
||||
|
||||
-- Make table of selected or hovered: path = filenames
|
||||
local selected_or_hovered = ya.sync(function()
|
||||
@ -45,11 +45,20 @@ local function is_command_available(cmd)
|
||||
if cmd_exists then
|
||||
return true
|
||||
else
|
||||
notify_error(string.format("%s not available", cmd), "error")
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
-- Archive command list --> string
|
||||
local function find_binary(cmd_list)
|
||||
for _, cmd in ipairs(cmd_list) do
|
||||
if is_command_available(cmd) then
|
||||
return cmd
|
||||
end
|
||||
end
|
||||
return cmd_list[1] -- Return first command as fallback
|
||||
end
|
||||
|
||||
-- Check if file exists
|
||||
local function file_exists(name)
|
||||
local f = io.open(name, "r")
|
||||
@ -87,10 +96,11 @@ return {
|
||||
-- Use appropriate archive command
|
||||
local archive_commands = {
|
||||
["%.zip$"] = { command = "zip", args = { "-r" } },
|
||||
["%.7z$"] = { command = "7z", args = { "a" } },
|
||||
["%.7z$"] = { command = { "7z", "7zz" }, args = { "a" } },
|
||||
["%.tar.gz$"] = { command = "tar", args = { "rpf" }, compress = "gzip" },
|
||||
["%.tar.xz$"] = { command = "tar", args = { "rpf" }, compress = "xz" },
|
||||
["%.tar.bz2$"] = { command = "tar", args = { "rpf" }, compress = "bzip2" },
|
||||
["%.tar.zst$"] = { command = "tar", args = { "rpf" }, compress = "zstd", compress_args = { "--rm" } },
|
||||
["%.tar$"] = { command = "tar", args = { "rpf" } },
|
||||
}
|
||||
|
||||
@ -116,6 +126,7 @@ return {
|
||||
compress = "7z",
|
||||
compress_args = { "a", "-tbzip2", "-sdel", output_name },
|
||||
},
|
||||
["%.tar.zst$"] = { command = "tar", args = { "rpf" }, compress = "zstd", compress_args = { "--rm" } },
|
||||
["%.tar$"] = { command = "tar", args = { "rpf" } },
|
||||
}
|
||||
end
|
||||
@ -131,6 +142,11 @@ return {
|
||||
end
|
||||
end
|
||||
|
||||
-- Check if archive command has multiple names
|
||||
if type(archive_cmd) == "table" then
|
||||
archive_cmd = find_binary(archive_cmd)
|
||||
end
|
||||
|
||||
-- Check if no archive command is available for the extention
|
||||
if not archive_cmd then
|
||||
notify_error("Unsupported file extention", "error")
|
||||
@ -139,11 +155,13 @@ return {
|
||||
|
||||
-- Exit if archive command is not available
|
||||
if not is_command_available(archive_cmd) then
|
||||
notify_error(string.format("%s not available", archive_cmd), "error")
|
||||
return
|
||||
end
|
||||
|
||||
-- Exit if compress command is not available
|
||||
if archive_compress and not is_command_available(archive_compress) then
|
||||
notify_error(string.format("%s compression not available", archive_compress), "error")
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
@ -16,26 +16,16 @@ and the [fast-enter.yazi](https://github.com/ourongxing/fast-enter.yazi) plugin.
|
||||
- [Augmented commands](#augmented-commands)
|
||||
- [New commands](#new-commands)
|
||||
- [Usage](#usage)
|
||||
- [Windows support?](#windows-support)
|
||||
- [Licence](#licence)
|
||||
|
||||
## Requirements
|
||||
|
||||
- [Yazi](https://github.com/sxyazi/yazi) v0.2.4+
|
||||
- [Unarchiver (unar)](https://theunarchiver.com/command-line)
|
||||
- [ls](https://www.gnu.org/software/coreutils/manual/html_node/ls-invocation.html#ls-invocation)
|
||||
- Linux or macOS
|
||||
- [Yazi](https://github.com/sxyazi/yazi) v0.3.0+
|
||||
- [`7z` or `7zz` command](https://github.com/p7zip-project/p7zip)
|
||||
- [`file` command](https://www.darwinsys.com/file/)
|
||||
|
||||
## Installation
|
||||
|
||||
### Yazi v0.2.5 and before (manual installation)
|
||||
|
||||
```sh
|
||||
git clone https://github.com/hankertrix/augment-command.yazi ~/.config/yazi/plugins/augment-command.yazi
|
||||
```
|
||||
|
||||
### Yazi nightly (latest Git commit) (package manager)
|
||||
|
||||
```sh
|
||||
# Add the plugin
|
||||
ya pack -a hankertrix/augment-command
|
||||
@ -49,24 +39,30 @@ 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. `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. |
|
||||
| `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](https://yazi-rs.github.io/docs/tips#smart-paste). Setting this option to `false` will use the default `paste` behaviour. You can also enable smart pasting by passing the `--smart` flag to the paste command. |
|
||||
| `enter_archives` | `true` or `false` | `true` | Automatically extract and enter archive files. This option requires [Unarchiver (unar)](https://theunarchiver.com/command-line) to be installed. |
|
||||
| `extract_behaviour` | `overwrite`, `rename`, or `skip` | `skip` | Determines how unar deals with existing files when extracting an archive. `overwrite` results in unar overwriting existing files when extracting. `rename` results in unar renaming the new files with the same name as existing files. `skip` results in unar skipping files that have the same name as existing files. Use the `man unar` command for more information. |
|
||||
| `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. |
|
||||
| `ignore_hidden_items` | `true` or `false` | `false` | Ignore hidden items when determining whether a directory only has one subdirectory and no other items. Setting this option to `false` will mean that hidden items in a directory will stop the plugin from skipping the single subdirectory. |
|
||||
| `wraparound_file_navigation` | `true` or `false` | `false` | Wrap around from the bottom to the top or from the top to the bottom when using the `arrow` command to navigate. |
|
||||
| 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. |
|
||||
| `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](https://yazi-rs.github.io/docs/tips#smart-paste). Setting this option to `false` will use the default `paste` behaviour. You can also enable smart pasting by passing the `--smart` flag to the paste command. |
|
||||
| `enter_archives` | `true` or `false` | `true` | Automatically extract and enter archive files. This option requires the [7z or 7zz command](https://github.com/p7zip-project/p7zip) 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. |
|
||||
| `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. |
|
||||
| `ignore_hidden_items` | `true` or `false` | `false` | Ignore hidden items when determining whether a directory only has one subdirectory and no other items. Setting this option to `false` will mean that hidden items in a directory will stop the plugin from skipping the single subdirectory. |
|
||||
| `wraparound_file_navigation` | `true` or `false` | `false` | 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. |
|
||||
| `sort_directories_first` | `true` or `false` | `true` | This option tells the plugin if you have sorted directories first in your [`yazi.toml` file](https://yazi-rs.github.io/docs/configuration/yazi#manager.sort_dir_first), located at `~/.config/yazi/yazi.toml` on Linux and macOS or `C:\Users\USERNAME\AppData\Roaming\yazi\config\yazi.toml` on Windows, where `USERNAME` is your Windows username. If you have set [`sort_dir_first`](https://yazi-rs.github.io/docs/configuration/yazi#manager.sort_dir_first) to `true` in your [`yazi.toml` file](https://yazi-rs.github.io/docs/configuration/yazi#manager.sort_dir_first), set this option to `true` as well. If you have set [`sort_dir_first`](https://yazi-rs.github.io/docs/configuration/yazi#manager.sort_dir_first) to `false` instead, set this option to `false` as well. This option only affects the `parent-arrow` command with `wraparound_file_navigation` set to `true`. If the [`sort_dir_first`](https://yazi-rs.github.io/docs/configuration/yazi#manager.sort_dir_first) setting doesn't match the plugin's `sort_directories_first` setting, i.e. Yazi's `sort_dir_first` is `true` but the plugin's `sort_directories_first` is `false`, or Yazi's `sort_dir_first` is `false` but the plugin's `sort_directories_first` is `true`, the wraparound functionality of the `parent-arrow` command will not work properly and may act erratically. The default value of `sort_directories_first` follows Yazi's [`sort_dir_first`](https://yazi-rs.github.io/docs/configuration/yazi#manager.sort_dir_first) default value, which is `true`. |
|
||||
|
||||
To configure this plugin, add the code below to your `~/.config/yazi/init.lua` file:
|
||||
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.
|
||||
|
||||
```lua
|
||||
-- ~/.config/yazi/init.lua
|
||||
-- ~/.config/yazi/init.lua for Linux and macOS
|
||||
-- C:\Users\USERNAME\AppData\Roaming\yazi\config\init.lua for Windows
|
||||
|
||||
-- Using the default configuration
|
||||
require("augment-command"):setup({
|
||||
@ -75,36 +71,42 @@ require("augment-command"):setup({
|
||||
smart_enter = true,
|
||||
smart_paste = false,
|
||||
enter_archives = true,
|
||||
extract_behaviour = "skip",
|
||||
extract_retries = 3,
|
||||
must_have_hovered_item = true,
|
||||
skip_single_subdirectory_on_enter = true,
|
||||
skip_single_subdirectory_on_leave = true,
|
||||
ignore_hidden_items = false,
|
||||
wraparound_file_navigation = false,
|
||||
sort_directories_first = true,
|
||||
})
|
||||
```
|
||||
|
||||
Note that you don't have to do this if you want to use the default configuration.
|
||||
You also can leave out configuration options that you would like to be left as default,
|
||||
for example:
|
||||
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.
|
||||
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
|
||||
-- ~/.config/yazi/init.lua for Linux and macOS
|
||||
-- C:\Users\USERNAME\AppData\Roaming\yazi\config\init.lua for Windows
|
||||
|
||||
-- Custom configuration
|
||||
require("augment-command"):setup({
|
||||
prompt = true,
|
||||
default_item_group_for_prompt = "none",
|
||||
extract_behaviour = "overwrite",
|
||||
extract_retries = 5,
|
||||
ignore_hidden_items = true,
|
||||
wraparound_file_navigation = true,
|
||||
sort_directories_first = false,
|
||||
})
|
||||
```
|
||||
|
||||
## What about the commands are augmented?
|
||||
|
||||
All commands that can operate on multiple files and directories,
|
||||
like `open`, `rename` and `remove`,
|
||||
like `open`, `rename`, `remove` and `shell`,
|
||||
as well as the new commands `editor` and `pager`,
|
||||
now determine an item group to operate on.
|
||||
By default, the command will operate on the hovered item,
|
||||
@ -125,7 +127,7 @@ then it will operate on the selected items.
|
||||
### Open (`open`)
|
||||
|
||||
- When `smart_enter` is set to `true`,
|
||||
calls the `enter` command when the hovered item is a directory.
|
||||
it calls the `enter` command when the hovered item is a directory.
|
||||
- `--no-skip` flag, which only applies
|
||||
when `smart_enter` is used as it is passed to the `enter` command.
|
||||
More details about this flag can be found at the documentation
|
||||
@ -134,21 +136,33 @@ then it will operate on the selected items.
|
||||
with support for skipping directories
|
||||
that contain only one subdirectory in the extracted archive.
|
||||
This can be disabled by setting `enter_archives` to `false` in the configuration.
|
||||
This feature requires
|
||||
[unarchiver (unar)](https://theunarchiver.com/command-line)
|
||||
to be installed as well as the
|
||||
[ls](https://www.gnu.org/software/coreutils/manual/html_node/ls-invocation.html#ls-invocation) command.
|
||||
This feature requires the
|
||||
[`7z` or `7zz` command](https://github.com/p7zip-project/p7zip)
|
||||
to be present to extract the archives.
|
||||
- If the archive file contains only a single file,
|
||||
the command will automatically extract it to the
|
||||
current directory instead of creating a folder
|
||||
for the contents of the archive.
|
||||
If this extracted file is also an archive file,
|
||||
the command will automatically
|
||||
extract its contents before deleting it.
|
||||
This feature requires the
|
||||
[`file` command](https://www.darwinsys.com/file/)
|
||||
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.
|
||||
|
||||
### Enter (`enter`)
|
||||
|
||||
- When `smart_enter` is set to `true`,
|
||||
calls the `open` command when the hovered item is a file.
|
||||
it calls the `open` command when the hovered item is a file.
|
||||
- Automatically skips directories that
|
||||
contain only one subdirectory when entering directories.
|
||||
This can be turned off by setting
|
||||
`skip_single_subdirectory_on_enter` to `false` in the configuration.
|
||||
This feature requires the
|
||||
[ls](https://www.gnu.org/software/coreutils/manual/html_node/ls-invocation.html#ls-invocation) command.
|
||||
- `--no-skip` flag. It stops the plugin from skipping directories
|
||||
that contain only one subdirectory when entering directories,
|
||||
even when `skip_single_subdirectory_on_enter` is set to `true`.
|
||||
@ -162,33 +176,21 @@ then it will operate on the selected items.
|
||||
This can be turned off by
|
||||
setting `skip_single_subdirectory_on_leave` to `false`
|
||||
in the configuration.
|
||||
This feature requires the
|
||||
[ls](https://www.gnu.org/software/coreutils/manual/html_node/ls-invocation.html#ls-invocation) command.
|
||||
- `--no-skip` flag. It stops the plugin
|
||||
from skipping directories that contain only one subdirectory,
|
||||
even when `skip_single_subdirectory_on_leave` is set to `true`.
|
||||
This allows you to set a key to navigate into directories
|
||||
This allows you to set a key to navigate out of directories
|
||||
without skipping the directories that contain only one subdirectory.
|
||||
|
||||
### Rename (`rename`)
|
||||
|
||||
- Unfortunately, to use the augmented `rename` command,
|
||||
you need to use the latest Git version of Yazi as
|
||||
[this commit](https://github.com/sxyazi/yazi/commit/9961251248c74202d8310085102d5809c279757c)
|
||||
adds the necessary `--hovered` flag.
|
||||
- If you don't use the latest Git version of Yazi,
|
||||
it just behaves like the provided `rename` command
|
||||
and the prompts don't do anything.
|
||||
- The `rename` command is augmented as stated in
|
||||
[this section above](#what-about-the-commands-are-augmented).
|
||||
|
||||
### Remove (`remove`)
|
||||
|
||||
- Unfortunately, to use the augmented `remove` command,
|
||||
you need to use the latest Git version of Yazi as
|
||||
[this commit](https://github.com/sxyazi/yazi/commit/9961251248c74202d8310085102d5809c279757c)
|
||||
adds the necessary `--hovered` flag.
|
||||
- If you don't use the latest Git version of Yazi,
|
||||
it just behaves like the provided `remove` command
|
||||
and the prompts don't do anything.
|
||||
- The `remove` command is augmented as stated in
|
||||
[this section above](#what-about-the-commands-are-augmented).
|
||||
|
||||
### Paste (`paste`)
|
||||
|
||||
@ -197,6 +199,9 @@ then it will operate on the selected items.
|
||||
into a hovered directory without entering it.
|
||||
If the hovered item is not a directory,
|
||||
the command pastes in the current directory instead.
|
||||
Otherwise, when `smart_paste` is set to `false`,
|
||||
the `paste` command will behave like the default
|
||||
`paste` command.
|
||||
- `--smart` flag to enable pasting in a hovered directory
|
||||
without entering the directory.
|
||||
This flag will cause the `paste` command to paste items
|
||||
@ -204,6 +209,74 @@ then it will operate on the selected items.
|
||||
This allows you to set a key to use smart paste
|
||||
instead of using smart paste for every paste command.
|
||||
|
||||
### Shell (`shell`)
|
||||
|
||||
- This command runs the shell command given with the augment stated in
|
||||
[this section above](#what-about-the-commands-are-augmented). 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 `shell` command provided by Yazi.
|
||||
- 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).
|
||||
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 --confirm"'
|
||||
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 --confirm''''
|
||||
desc = "Open the editor"
|
||||
|
||||
[[manager.prepend_keymap]]
|
||||
on = [ "i" ]
|
||||
run = '''plugin augment-command --args="shell '$PAGER $@' --block --confirm"'''
|
||||
desc = "Open the pager"
|
||||
```
|
||||
|
||||
- `--exit-if-directory` flag 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 the `pager` command.
|
||||
The `pager` command is essentially:
|
||||
|
||||
```toml
|
||||
# ~/.config/yazi/keymap.toml on Linux and macOS
|
||||
# C:\Users\USERNAME\AppData\Roaming\yazi\config\keymap.toml on Windows
|
||||
|
||||
[[manager.prepend_keymap]]
|
||||
on = [ "i" ]
|
||||
run = '''plugin augment-command --args="shell '$PAGER $@' --block --confirm --exit-if-directory"'''
|
||||
desc = "Open the pager"
|
||||
```
|
||||
|
||||
### Arrow (`arrow`)
|
||||
|
||||
- When `wraparound_file_navigation` is set to `true`,
|
||||
@ -217,60 +290,129 @@ then it will operate on the selected items.
|
||||
|
||||
- This command behaves like the `arrow` command,
|
||||
but in the parent directory.
|
||||
It allows you to navigate the parent directory
|
||||
It allows you to navigate in the parent directory
|
||||
without leaving the current directory.
|
||||
- When `wraparound_file_navigation` is set to `true`,
|
||||
this command will also wrap around from the bottom to the top or
|
||||
from top to the bottom when navigating in the parent directory.
|
||||
For this feature to work, you will need the
|
||||
[ls](https://www.gnu.org/software/coreutils/manual/html_node/ls-invocation.html#ls-invocation) command.
|
||||
You will also need to have your directories
|
||||
sorted first for this feature to work,
|
||||
i.e. in your `~/.config/yazi/yazi.toml` file:
|
||||
For this feature to work properly, the
|
||||
[`sort_dir_first`](https://yazi-rs.github.io/docs/configuration/yazi#manager.sort_dir_first)
|
||||
option in your `~/.config/yazi/yazi.toml` file on Linux and macOS,
|
||||
or your `C:\Users\USERNAME\AppData\Roaming\yazi\config\yazi.toml`
|
||||
file on Windows, where `USERNAME` is your Windows username,
|
||||
has to match the plugin's `sort_directories_first` option,
|
||||
i.e. if you have set the
|
||||
[`sort_dir_first`](https://yazi-rs.github.io/docs/configuration/yazi#manager.sort_dir_first)
|
||||
to `true` in your `~/.config/yazi/yazi.toml` file on Linux and macOS,
|
||||
or your `C:\Users\USERNAME\AppData\Roaming\yazi\config\yazi.toml` on Windows,
|
||||
like so:
|
||||
|
||||
```toml
|
||||
# ~/.config/yazi/yazi.toml
|
||||
[manager]
|
||||
sort_dir_first = true
|
||||
```
|
||||
```toml
|
||||
# ~/.config/yazi/yazi.toml on Linux and macOS
|
||||
# C:\Users\USERNAME\AppData\Roaming\yazi\config\yazi.toml on Windows
|
||||
|
||||
[manager]
|
||||
sort_dir_first = true
|
||||
```
|
||||
|
||||
Then `sort_directories_first` should be set to `true`
|
||||
as well in your `~/.config/yazi/init.lua` file on Linux and macOS,
|
||||
or your `C:\Users\USERNAME\AppData\Roaming\yazi\config\yazi.toml`
|
||||
file on Windows, where `USERNAME` is your Windows username, like so:
|
||||
|
||||
```lua
|
||||
-- ~/.config/yazi/init.lua on Linux and macOS
|
||||
-- C:\Users\USERNAME\AppData\Roaming\yazi\config\init.lua on Windows
|
||||
|
||||
require("augment-command"):setup({
|
||||
sort_directories_first = true
|
||||
})
|
||||
```
|
||||
|
||||
If your `~/.config/yazi/yazi.toml` file on Linux and macOS, or your
|
||||
`C:\Users\USERNAME\AppData\Roaming\yazi\config\yazi.toml` file on Windows,
|
||||
where `USERNAME` is your Windows username, has
|
||||
[`sort_dir_first`](https://yazi-rs.github.io/docs/configuration/yazi#manager.sort_dir_first)
|
||||
set to `false`, like so:
|
||||
|
||||
```toml
|
||||
# ~/.config/yazi/yazi.toml on Linux and macOS
|
||||
# C:\Users\USERNAME\AppData\Roaming\yazi\config\yazi.toml on Windows
|
||||
|
||||
[manager]
|
||||
sort_dir_first = false
|
||||
```
|
||||
|
||||
Then `sort_directories_first` should be set to `false`
|
||||
as well in your `~/.config/yazi/init.lua` file on Linux and macOS,
|
||||
or your `C:\Users\USERNAME\AppData\Roaming\yazi\config\yazi.toml`
|
||||
file on Windows, where `USERNAME` is your Windows username, like so:
|
||||
|
||||
```lua
|
||||
-- ~/.config/yazi/init.lua on Linux and macOS
|
||||
-- C:\Users\USERNAME\AppData\Roaming\yazi\config\init.lua on Windows
|
||||
|
||||
require("augment-command"):setup({
|
||||
sort_directories_first = false
|
||||
})
|
||||
```
|
||||
|
||||
The default value of `sort_directories_first` follows Yazi's
|
||||
[`sort_dir_first`](https://yazi-rs.github.io/docs/configuration/yazi#manager.sort_dir_first)
|
||||
default value, which is `true`.
|
||||
|
||||
- You can also replicate this using this series of commands below,
|
||||
but it doesn't work as well,
|
||||
and doesn't support wraparound navigation:
|
||||
|
||||
```toml
|
||||
# ~/.config/yazi/keymap.toml
|
||||
```toml
|
||||
# ~/.config/yazi/keymap.toml on Linux and macOS
|
||||
# C:\Users\USERNAME\AppData\Roaming\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 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"
|
||||
```
|
||||
# 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"
|
||||
```
|
||||
|
||||
### Editor (`editor`)
|
||||
|
||||
- This command opens the default editor set by the `$EDITOR` environment variable.
|
||||
- The `editor` command opens the default editor set by the `$EDITOR` environment variable.
|
||||
- The command is also augmented as stated in
|
||||
[this section above](#what-about-the-commands-are-augmented).
|
||||
|
||||
### Pager (`pager`)
|
||||
|
||||
- This command opens the default pager set by the `$PAGER` environment variable.
|
||||
- The `pager` command opens the default pager set by the `$PAGER` environment variable.
|
||||
- The command is also augmented as stated in
|
||||
[this section above](#what-about-the-commands-are-augmented).
|
||||
- The `pager` command 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 Yazi to send a notification.
|
||||
|
||||
## Usage
|
||||
|
||||
Add the commands that you would like to use to your `keymap.toml` file,
|
||||
located at `~/.config/yazi/keymap.toml`,
|
||||
in this format:
|
||||
located at `~/.config/yazi/keymap.toml` on Linux and macOS
|
||||
and at `C:\Users\USERNAME\AppData\Roaming\yazi\config\keymap.toml`
|
||||
on Windows, in this format:
|
||||
|
||||
```toml
|
||||
# ~/.config/yazi/keymap.toml
|
||||
# ~/.config/yazi/keymap.toml on Linux and macOS
|
||||
# C:\Users\USERNAME\AppData\Roaming\yazi\config\keymap.toml on Windows
|
||||
|
||||
[[manager.prepend_keymap]]
|
||||
on = [ "key" ]
|
||||
run = "plugin augment-command --args='command arguments --flags --options=42'"
|
||||
@ -280,7 +422,9 @@ desc = "Description"
|
||||
For example, to use the augmented `enter` command:
|
||||
|
||||
```toml
|
||||
# ~/.config/yazi/keymap.toml
|
||||
# ~/.config/yazi/keymap.toml on Linux and macOS
|
||||
# C:\Users\USERNAME\AppData\Roaming\yazi\config\keymap.toml on Windows
|
||||
|
||||
[[manager.prepend_keymap]]
|
||||
on = [ "l" ]
|
||||
run = "plugin augment-command --args='enter'"
|
||||
@ -290,7 +434,9 @@ 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:
|
||||
|
||||
```toml
|
||||
# ~/.config/yazi/keymap.toml
|
||||
# ~/.config/yazi/keymap.toml on Linux and macOS
|
||||
# C:\Users\USERNAME\AppData\Roaming\yazi\config\keymap.toml on Windows
|
||||
|
||||
[[manager.prepend_keymap]]
|
||||
on = [ "k" ]
|
||||
run = "plugin augment-command --args='arrow -1'"
|
||||
@ -324,10 +470,6 @@ For a full configuration example,
|
||||
you can take a look at
|
||||
[my `keymap.toml` file](https://github.com/hankertrix/Dotfiles/blob/master/.config/yazi/keymap.toml).
|
||||
|
||||
## Windows support?
|
||||
|
||||
Pull requests for Windows support are welcome!
|
||||
|
||||
## Licence
|
||||
|
||||
This plugin is licenced under the GNU GPL v3 licence.
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -7,7 +7,7 @@ https://github.com/yazi-rs/plugins/assets/17523360/7aa3abc2-d057-498c-8473-a6282
|
||||
## Installation
|
||||
|
||||
```sh
|
||||
ya pack -a yazi-rs/plugins#chmod
|
||||
ya pack -a yazi-rs/plugins:chmod
|
||||
```
|
||||
|
||||
## Usage
|
||||
@ -22,3 +22,7 @@ desc = "Chmod on selected files"
|
||||
```
|
||||
|
||||
Make sure the <kbd>c</kbd> => <kbd>m</kbd> key is not used elsewhere.
|
||||
|
||||
## License
|
||||
|
||||
This plugin is MIT-licensed. For more information check the [LICENSE](LICENSE) file.
|
||||
|
||||
@ -7,6 +7,10 @@ Preview audio metadata and cover on [Yazi](https://github.com/sxyazi/yazi).
|
||||
## Installation
|
||||
|
||||
```sh
|
||||
# Automatically with yazi 0.3.0
|
||||
ya pack -a "Sonico98/exifaudio"
|
||||
|
||||
# Or manually under:
|
||||
# Linux/macOS
|
||||
git clone https://github.com/Sonico98/exifaudio.yazi.git ~/.config/yazi/plugins/exifaudio.yazi
|
||||
|
||||
@ -27,6 +31,8 @@ prepend_previewers = [
|
||||
|
||||
Make sure you have [exiftool](https://exiftool.org/) installed and in your `PATH`.
|
||||
|
||||
Optional: if you have [mediainfo](https://mediaarea.net/en/MediaInfo) installed and in your `PATH`, it will be used instead for more accurate metadata. Exiftool is still required to display the cover.
|
||||
|
||||
## Thanks
|
||||
|
||||
Thanks to [sxyazi](https://github.com/sxyazi) for the PDF previewer code, on which this previewer is based on.
|
||||
|
||||
@ -1,11 +1,14 @@
|
||||
local M = {}
|
||||
|
||||
function M:peek()
|
||||
local cache = ya.file_cache(self)
|
||||
if not cache then
|
||||
return
|
||||
function GetPath(str)
|
||||
local sep = '/'
|
||||
if ya.target_family() == "windows" then
|
||||
sep = '\\'
|
||||
end
|
||||
return str:match("(.*"..sep..")")
|
||||
end
|
||||
|
||||
function Exiftool(...)
|
||||
local child = Command("exiftool")
|
||||
:args({
|
||||
"-q", "-q", "-S", "-Title", "-SortName",
|
||||
@ -16,11 +19,58 @@ function M:peek()
|
||||
"-AlbumArtistSortOrder", "-Genre", "-TrackNumber",
|
||||
"-Year", "-Duration", "-SampleRate",
|
||||
"-AudioSampleRate", "-AudioBitrate", "-AvgBitrate",
|
||||
"-Channels", "-AudioChannels", tostring(self.file.url),
|
||||
"-Channels", "-AudioChannels", tostring(...),
|
||||
})
|
||||
:stdout(Command.PIPED)
|
||||
:stderr(Command.NULL)
|
||||
:spawn()
|
||||
:spawn()
|
||||
return child
|
||||
end
|
||||
|
||||
function Mediainfo(...)
|
||||
local file, cache_dir = ...
|
||||
local template = cache_dir.."mediainfo.txt"
|
||||
local child = Command("mediainfo")
|
||||
:args({
|
||||
"--Output=file://"..template, tostring(file)
|
||||
})
|
||||
:stdout(Command.PIPED)
|
||||
:stderr(Command.NULL)
|
||||
:spawn()
|
||||
return child
|
||||
end
|
||||
|
||||
function M:peek()
|
||||
local cache = ya.file_cache(self)
|
||||
if not cache then
|
||||
return
|
||||
end
|
||||
|
||||
-- Get cache dir to find the mediainfo template file
|
||||
local cache_dir = GetPath(tostring(cache))
|
||||
|
||||
-- Try mediainfo, otherwise use exiftool
|
||||
pcall(display_metadata_legacy)
|
||||
pcall(display_metadata)
|
||||
local status, child = pcall(Mediainfo, self.file.url, cache_dir)
|
||||
if not status or child == nil then
|
||||
status, child = pcall(Exiftool, self.file.url)
|
||||
if not status or child == nil then
|
||||
local error = ui.Line { ui.Span("Make sure exiftool is installed and in your PATH") }
|
||||
-- TODO)) Remove legacy method when v0.4 gets released
|
||||
local function display_error_legacy()
|
||||
local p = ui.Paragraph(self.area, { error }):wrap(ui.Paragraph.WRAP)
|
||||
ya.preview_widgets(self, { p })
|
||||
end
|
||||
local function display_error()
|
||||
local p = ui.Text(error):area(self.area):wrap(ui.Text.WRAP)
|
||||
ya.preview_widgets(self, { p })
|
||||
end
|
||||
pcall(display_error_legacy)
|
||||
pcall(display_error)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
local limit = self.area.h
|
||||
local i, metadata = 0, {}
|
||||
@ -34,16 +84,27 @@ function M:peek()
|
||||
|
||||
i = i + 1
|
||||
if i > self.skip then
|
||||
local m_title, m_tag = prettify(next)
|
||||
local ti = ui.Span(m_title):bold()
|
||||
local ta = ui.Span(m_tag)
|
||||
table.insert(metadata, ui.Line{ti, ta})
|
||||
table.insert(metadata, ui.Line{})
|
||||
local m_title, m_tag = Prettify(next)
|
||||
if m_title ~= "" and m_tag ~= "" then
|
||||
local ti = ui.Span(m_title):bold()
|
||||
local ta = ui.Span(m_tag)
|
||||
table.insert(metadata, ui.Line{ti, ta})
|
||||
table.insert(metadata, ui.Line{})
|
||||
end
|
||||
end
|
||||
until i >= self.skip + limit
|
||||
|
||||
local p = ui.Paragraph(self.area, metadata):wrap(ui.Paragraph.WRAP)
|
||||
ya.preview_widgets(self, { p })
|
||||
|
||||
-- TODO)) Remove legacy method when v0.4 gets released
|
||||
local function display_metadata_legacy()
|
||||
local p = ui.Paragraph(self.area, metadata):wrap(ui.Paragraph.WRAP)
|
||||
ya.preview_widgets(self, { p })
|
||||
end
|
||||
local function display_metadata()
|
||||
local p = ui.Text(metadata):area(self.area):wrap(ui.Text.WRAP)
|
||||
ya.preview_widgets(self, { p })
|
||||
end
|
||||
pcall(display_metadata_legacy)
|
||||
pcall(display_metadata)
|
||||
|
||||
local cover_width = self.area.w / 2 - 5
|
||||
local cover_height = (self.area.h / 4) + 3
|
||||
@ -60,7 +121,7 @@ function M:peek()
|
||||
end
|
||||
end
|
||||
|
||||
function prettify(metadata)
|
||||
function Prettify(metadata)
|
||||
local substitutions = {
|
||||
Sortname = "Sort Title:",
|
||||
SortName = "Sort Title:",
|
||||
@ -99,11 +160,19 @@ function prettify(metadata)
|
||||
-- Separate the tag title from the tag data
|
||||
local t={}
|
||||
for str in string.gmatch(metadata , "([^"..":".."]+)") do
|
||||
table.insert(t, str)
|
||||
if str ~= "\n" then
|
||||
table.insert(t, str)
|
||||
else
|
||||
table.insert(t, nil)
|
||||
end
|
||||
end
|
||||
|
||||
-- Add back semicolon to title, rejoin tag data if it happened to contain a semicolon
|
||||
return t[1]..":", table.concat(t, ":", 2)
|
||||
local title, tag_data = "", ""
|
||||
if t[1] ~= nil then
|
||||
title, tag_data = t[1]..":", table.concat(t, ":", 2)
|
||||
end
|
||||
return title, tag_data
|
||||
|
||||
end
|
||||
|
||||
@ -123,6 +192,33 @@ function M:preload()
|
||||
return 1
|
||||
end
|
||||
|
||||
local mediainfo_template = 'General;"\
|
||||
$if(%Track%,Title: %Track%,)\
|
||||
$if(%Track/Sort%,Sort Title: %Track/Sort%,)\
|
||||
$if(%Title/Sort%,Sort Title: %Title/Sort%,)\
|
||||
$if(%TITLESORT%,Sort Title: %TITLESORT%,)\
|
||||
$if(%Performer%,Artist: %Performer%,)\
|
||||
$if(%Performer/Sort%,Sort Artist: %Performer/Sort%,)\
|
||||
$if(%ARTISTSORT%,Sort Artist: %ARTISTSORT%,)\
|
||||
$if(%Album%,Album: %Album%,)\
|
||||
$if(%Album/Sort%,Sort Album: %Album/Sort%)\
|
||||
$if(%ALBUMSORT%,Sort Album: %ALBUMSORT%)\
|
||||
$if(%Album/Performer%,Album Artist: %Album/Performer%)\
|
||||
$if(%Album/Performer/Sort%,Sort Album Artist: %Album/Performer/Sort%)\
|
||||
$if(%Genre%,Genre: %Genre%)\
|
||||
$if(%Track/Position%,Track Number: %Track/Position%)\
|
||||
$if(%Recorded_Date%,Year: %Recorded_Date%)\
|
||||
$if(%Duration/String%,Duration: %Duration/String%)\
|
||||
$if(%BitRate/String%,Bitrate: %BitRate/String%)\
|
||||
"\
|
||||
Audio;"Sample Rate: %SamplingRate%\
|
||||
Channels: %Channel(s)%"\
|
||||
'
|
||||
|
||||
-- Write the mediainfo template file into yazi's cache dir
|
||||
local cache_dir = GetPath(tostring(cache))
|
||||
fs.write(Url(cache_dir.."mediainfo.txt"), mediainfo_template)
|
||||
|
||||
local output = Command("exiftool")
|
||||
:args({ "-b", "-CoverArt", "-Picture", tostring(self.file.url) })
|
||||
:stdout(Command.PIPED)
|
||||
|
||||
@ -7,7 +7,7 @@ Add a full border to Yazi to make it look fancier.
|
||||
## Installation
|
||||
|
||||
```sh
|
||||
ya pack -a yazi-rs/plugins#full-border
|
||||
ya pack -a yazi-rs/plugins:full-border
|
||||
```
|
||||
|
||||
## Usage
|
||||
@ -18,5 +18,15 @@ Add this to your `init.lua` to enable the plugin:
|
||||
require("full-border"):setup()
|
||||
```
|
||||
|
||||
This plugin overrides the [`Manager.render`](https://github.com/sxyazi/yazi/blob/latest/yazi-plugin/preset/components/manager.lua) method,
|
||||
you might need to check if any other plugins that also need to override it are enabled.
|
||||
Or you can customize the border type:
|
||||
|
||||
```lua
|
||||
require("full-border"):setup {
|
||||
-- Available values: ui.Border.PLAIN, ui.Border.ROUNDED
|
||||
type = ui.Border.ROUNDED,
|
||||
}
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
This plugin is MIT-licensed. For more information check the [LICENSE](LICENSE) file.
|
||||
|
||||
@ -1,13 +1,29 @@
|
||||
local function setup()
|
||||
-- TODO: remove this once v0.4 is released
|
||||
local v4 = function(typ, area, ...)
|
||||
if typ == "bar" then
|
||||
return ui.Table and ui.Bar(...):area(area) or ui.Bar(area, ...)
|
||||
else
|
||||
return ui.Table and ui.Border(...):area(area) or ui.Border(area, ...)
|
||||
end
|
||||
end
|
||||
|
||||
local function setup(_, opts)
|
||||
local type = opts and opts.type or ui.Border.ROUNDED
|
||||
local old_build = Tab.build
|
||||
|
||||
Tab.build = function(self, ...)
|
||||
local bar = function(c, x, y)
|
||||
if x <= 0 or x == self._area.w - 1 then
|
||||
return ui.Bar(ui.Rect.default, ui.Bar.TOP)
|
||||
return v4("bar", ui.Rect.default, ui.Bar.TOP)
|
||||
end
|
||||
|
||||
return ui.Bar(
|
||||
ui.Rect { x = x, y = math.max(0, y), w = ya.clamp(0, self._area.w - x, 1), h = math.min(1, self._area.h) },
|
||||
ui.Rect({
|
||||
x = x,
|
||||
y = math.max(0, y),
|
||||
w = ya.clamp(0, self._area.w - x, 1),
|
||||
h = math.min(1, self._area.h),
|
||||
}),
|
||||
ui.Bar.TOP
|
||||
):symbol(c)
|
||||
end
|
||||
@ -15,13 +31,13 @@ local function setup()
|
||||
local c = self._chunks
|
||||
self._chunks = {
|
||||
c[1]:padding(ui.Padding.y(1)),
|
||||
c[2]:padding(c[1].w > 0 and ui.Padding.y(1) or ui.Padding(1, 0, 1, 1)),
|
||||
c[2]:padding(ui.Padding(c[1].w > 0 and 0 or 1, c[3].w > 0 and 0 or 1, 1, 1)),
|
||||
c[3]:padding(ui.Padding.y(1)),
|
||||
}
|
||||
|
||||
local style = THEME.manager.border_style
|
||||
self._base = ya.list_merge(self._base or {}, {
|
||||
ui.Border(self._area, ui.Border.ALL):type(ui.Border.ROUNDED):style(style),
|
||||
ui.Border(self._area, ui.Border.ALL):type(type):style(style),
|
||||
ui.Bar(self._chunks[1], ui.Bar.RIGHT):style(style),
|
||||
ui.Bar(self._chunks[3], ui.Bar.LEFT):style(style),
|
||||
|
||||
|
||||
21
config/yazi/plugins/git.yazi/LICENSE
Normal file
21
config/yazi/plugins/git.yazi/LICENSE
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2023 yazi-rs
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
81
config/yazi/plugins/git.yazi/README.md
Normal file
81
config/yazi/plugins/git.yazi/README.md
Normal file
@ -0,0 +1,81 @@
|
||||
# git.yazi
|
||||
|
||||
> [!NOTE]
|
||||
> Yazi v0.3.3 or later is required for this plugin to work.
|
||||
|
||||
Show the status of Git file changes as linemode in the file list.
|
||||
|
||||
https://github.com/user-attachments/assets/34976be9-a871-4ffe-9d5a-c4cdd0bf4576
|
||||
|
||||
## Installation
|
||||
|
||||
```sh
|
||||
ya pack -a yazi-rs/plugins:git
|
||||
```
|
||||
|
||||
## Setup
|
||||
|
||||
Add the following to your `~/.config/yazi/init.lua`:
|
||||
|
||||
```lua
|
||||
require("git"):setup()
|
||||
```
|
||||
|
||||
And register it as fetchers in your `~/.config/yazi/yazi.toml`:
|
||||
|
||||
```toml
|
||||
[[plugin.prepend_fetchers]]
|
||||
id = "git"
|
||||
name = "*"
|
||||
run = "git"
|
||||
|
||||
[[plugin.prepend_fetchers]]
|
||||
id = "git"
|
||||
name = "*/"
|
||||
run = "git"
|
||||
```
|
||||
|
||||
## Advanced
|
||||
|
||||
> [!NOTE]
|
||||
> This section currently requires Yazi nightly that includes https://github.com/sxyazi/yazi/pull/1637
|
||||
|
||||
You can customize the [Style](https://yazi-rs.github.io/docs/plugins/layout#style) of the status sign with:
|
||||
|
||||
- `THEME.git.modified`
|
||||
- `THEME.git.added`
|
||||
- `THEME.git.untracked`
|
||||
- `THEME.git.ignored`
|
||||
- `THEME.git.deleted`
|
||||
- `THEME.git.updated`
|
||||
|
||||
For example:
|
||||
|
||||
```lua
|
||||
-- ~/.config/yazi/init.lua
|
||||
THEME.git = THEME.git or {}
|
||||
THEME.git.modified = ui.Style():fg("blue")
|
||||
THEME.git.deleted = ui.Style():fg("red"):bold()
|
||||
```
|
||||
|
||||
You can also customize the text of the status sign with:
|
||||
|
||||
- `THEME.git.modified_sign`
|
||||
- `THEME.git.added_sign`
|
||||
- `THEME.git.untracked_sign`
|
||||
- `THEME.git.ignored_sign`
|
||||
- `THEME.git.deleted_sign`
|
||||
- `THEME.git.updated_sign`
|
||||
|
||||
For example:
|
||||
|
||||
```lua
|
||||
-- ~/.config/yazi/init.lua
|
||||
THEME.git = THEME.git or {}
|
||||
THEME.git.modified_sign = "M"
|
||||
THEME.git.deleted_sign = "D"
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
This plugin is MIT-licensed. For more information check the [LICENSE](LICENSE) file.
|
||||
198
config/yazi/plugins/git.yazi/init.lua
Normal file
198
config/yazi/plugins/git.yazi/init.lua
Normal file
@ -0,0 +1,198 @@
|
||||
local WIN = ya.target_family() == "windows"
|
||||
local PATS = {
|
||||
{ "[MT]", 6 }, -- Modified
|
||||
{ "[AC]", 5 }, -- Added
|
||||
{ "?$", 4 }, -- Untracked
|
||||
{ "!$", 3 }, -- Ignored
|
||||
{ "D", 2 }, -- Deleted
|
||||
{ "U", 1 }, -- Updated
|
||||
{ "[AD][AD]", 1 }, -- Updated
|
||||
}
|
||||
|
||||
local function match(line)
|
||||
local signs = line:sub(1, 2)
|
||||
for _, p in ipairs(PATS) do
|
||||
local path
|
||||
if signs:find(p[1]) then
|
||||
path = line:sub(4, 4) == '"' and line:sub(5, -2) or line:sub(4)
|
||||
path = WIN and path:gsub("/", "\\") or path
|
||||
end
|
||||
if not path then
|
||||
elseif path:find("[/\\]$") then
|
||||
return p[2] == 3 and 30 or p[2], path:sub(1, -2)
|
||||
else
|
||||
return p[2], path
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function root(cwd)
|
||||
repeat
|
||||
local cha = fs.cha(cwd:join(".git"))
|
||||
if cha and cha.is_dir then
|
||||
return tostring(cwd)
|
||||
end
|
||||
cwd = cwd:parent()
|
||||
until not cwd
|
||||
end
|
||||
|
||||
local function bubble_up(changed)
|
||||
local new, empty = {}, Url("")
|
||||
for k, v in pairs(changed) do
|
||||
if v ~= 3 and v ~= 30 then
|
||||
local url = Url(k):parent()
|
||||
while url and url ~= empty do
|
||||
local s = tostring(url)
|
||||
new[s] = (new[s] or 0) > v and new[s] or v
|
||||
url = url:parent()
|
||||
end
|
||||
end
|
||||
end
|
||||
return new
|
||||
end
|
||||
|
||||
local function propagate_down(ignored, cwd, repo)
|
||||
local new, rel = {}, cwd:strip_prefix(repo)
|
||||
for k, v in pairs(ignored) do
|
||||
if v == 30 then
|
||||
if rel:starts_with(k) then
|
||||
new[tostring(repo:join(rel))] = 30
|
||||
elseif cwd == repo:join(k):parent() then
|
||||
new[k] = 3
|
||||
end
|
||||
end
|
||||
end
|
||||
return new
|
||||
end
|
||||
|
||||
local add = ya.sync(function(st, cwd, repo, changed)
|
||||
st.dirs[cwd] = repo
|
||||
st.repos[repo] = st.repos[repo] or {}
|
||||
for k, v in pairs(changed) do
|
||||
if v == 0 then
|
||||
st.repos[repo][k] = nil
|
||||
elseif v == 30 then
|
||||
st.dirs[k] = ""
|
||||
else
|
||||
st.repos[repo][k] = v
|
||||
end
|
||||
end
|
||||
ya.render()
|
||||
end)
|
||||
|
||||
local remove = ya.sync(function(st, cwd)
|
||||
local dir = st.dirs[cwd]
|
||||
if not dir then
|
||||
return
|
||||
end
|
||||
|
||||
ya.render()
|
||||
st.dirs[cwd] = nil
|
||||
if not st.repos[dir] then
|
||||
return
|
||||
end
|
||||
|
||||
for _, r in pairs(st.dirs) do
|
||||
if r == dir then
|
||||
return
|
||||
end
|
||||
end
|
||||
st.repos[dir] = nil
|
||||
end)
|
||||
|
||||
local function setup(st, opts)
|
||||
st.dirs = {}
|
||||
st.repos = {}
|
||||
|
||||
opts = opts or {}
|
||||
opts.order = opts.order or 1500
|
||||
|
||||
-- Chosen by ChatGPT fairly, PRs are welcome to adjust them
|
||||
local t = THEME.git or {}
|
||||
local styles = {
|
||||
[6] = t.modified and ui.Style(t.modified) or ui.Style():fg("#ffa500"),
|
||||
[5] = t.added and ui.Style(t.added) or ui.Style():fg("#32cd32"),
|
||||
[4] = t.untracked and ui.Style(t.untracked) or ui.Style():fg("#a9a9a9"),
|
||||
[3] = t.ignored and ui.Style(t.ignored) or ui.Style():fg("#696969"),
|
||||
[2] = t.deleted and ui.Style(t.deleted) or ui.Style():fg("#ff4500"),
|
||||
[1] = t.updated and ui.Style(t.updated) or ui.Style():fg("#1e90ff"),
|
||||
}
|
||||
local signs = {
|
||||
[6] = t.modified_sign and t.modified_sign or "",
|
||||
[5] = t.added_sign and t.added_sign or "",
|
||||
[4] = t.untracked_sign and t.untracked_sign or "",
|
||||
[3] = t.ignored_sign and t.ignored_sign or "",
|
||||
[2] = t.deleted_sign and t.deleted_sign or "",
|
||||
[1] = t.updated_sign and t.updated_sign or "U",
|
||||
}
|
||||
|
||||
Linemode:children_add(function(self)
|
||||
local url = self._file.url
|
||||
local dir = st.dirs[tostring(url:parent())]
|
||||
local change
|
||||
if dir then
|
||||
change = dir == "" and 3 or st.repos[dir][tostring(url):sub(#dir + 2)]
|
||||
end
|
||||
|
||||
if not change or signs[change] == "" then
|
||||
return ui.Line("")
|
||||
elseif self._file:is_hovered() then
|
||||
return ui.Line { ui.Span(" "), ui.Span(signs[change]) }
|
||||
else
|
||||
return ui.Line { ui.Span(" "), ui.Span(signs[change]):style(styles[change]) }
|
||||
end
|
||||
end, opts.order)
|
||||
end
|
||||
|
||||
local function fetch(self)
|
||||
local cwd = self.files[1].url:parent()
|
||||
local repo = root(cwd)
|
||||
if not repo then
|
||||
remove(tostring(cwd))
|
||||
return 1
|
||||
end
|
||||
|
||||
local paths = {}
|
||||
for _, f in ipairs(self.files) do
|
||||
paths[#paths + 1] = tostring(f.url)
|
||||
end
|
||||
|
||||
-- stylua: ignore
|
||||
local output, err = Command("git")
|
||||
:cwd(tostring(cwd))
|
||||
:args({ "--no-optional-locks", "-c", "core.quotePath=", "status", "--porcelain", "-unormal", "--no-renames", "--ignored=matching" })
|
||||
:args(paths)
|
||||
:stdout(Command.PIPED)
|
||||
:output()
|
||||
if not output then
|
||||
ya.err("Cannot spawn git command, error code " .. tostring(err))
|
||||
return 0
|
||||
end
|
||||
|
||||
local changed, ignored = {}, {}
|
||||
for line in output.stdout:gmatch("[^\r\n]+") do
|
||||
local sign, path = match(line)
|
||||
if sign == 30 then
|
||||
ignored[path] = sign
|
||||
else
|
||||
changed[path] = sign
|
||||
end
|
||||
end
|
||||
|
||||
if self.files[1].cha.is_dir then
|
||||
ya.dict_merge(changed, bubble_up(changed))
|
||||
ya.dict_merge(changed, propagate_down(ignored, cwd, Url(repo)))
|
||||
else
|
||||
ya.dict_merge(changed, propagate_down(ignored, cwd, Url(repo)))
|
||||
end
|
||||
|
||||
for _, p in ipairs(paths) do
|
||||
local s = p:sub(#repo + 2)
|
||||
changed[s] = changed[s] or 0
|
||||
end
|
||||
add(tostring(cwd), repo, changed)
|
||||
|
||||
return 3
|
||||
end
|
||||
|
||||
return { setup = setup, fetch = fetch }
|
||||
@ -1,9 +1,9 @@
|
||||
# glow.yazi
|
||||
|
||||
Plugin for [Yazi](https://github.com/sxyazi/yazi) to preview markdown files with [glow](https://github.com/charmbracelet/glow). To install, clone the repo inside your `~/.config/yazi/plugins/`:
|
||||
Plugin for [Yazi](https://github.com/sxyazi/yazi) to preview markdown files with [glow](https://github.com/charmbracelet/glow). To install, run the below mentioned command:
|
||||
|
||||
```bash
|
||||
git clone https://github.com/Reledia/glow.yazi.git
|
||||
ya pack -a Reledia/glow
|
||||
```
|
||||
|
||||
then include it in your `yazi.toml` to use:
|
||||
|
||||
@ -9,6 +9,7 @@ function M:peek()
|
||||
tostring(self.area.w),
|
||||
tostring(self.file.url),
|
||||
})
|
||||
:env("CLICOLOR_FORCE", "1")
|
||||
:stdout(Command.PIPED)
|
||||
:stderr(Command.PIPED)
|
||||
:spawn()
|
||||
@ -57,9 +58,13 @@ function M:seek(units)
|
||||
end
|
||||
|
||||
function M:fallback_to_builtin()
|
||||
local _, bound = ya.preview_code(self)
|
||||
local err, bound = ya.preview_code(self)
|
||||
if bound then
|
||||
ya.manager_emit("peek", { tostring(bound), only_if = tostring(self.file.url), upper_bound = "" })
|
||||
ya.manager_emit("peek", { bound, only_if = self.file.url, upper_bound = true })
|
||||
elseif err and not err:find("cancelled", 1, true) then
|
||||
ya.preview_widgets(self, {
|
||||
ui.Paragraph(self.area, { ui.Line(err):reverse() }),
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
# hexyl.yazi
|
||||
|
||||
Preview any file on [Yazi](https://github.com/sxyazi/yazi) using [hexyl](https://github.com/sharkdp/hexyl). To install, clone the repo inside your `~/.config/yazi/plugins/`:
|
||||
Preview any file on [Yazi](https://github.com/sxyazi/yazi) using [hexyl](https://github.com/sharkdp/hexyl). To install, use the `ya pack` cli utility:
|
||||
|
||||
```bash
|
||||
git clone https://github.com/Reledia/hexyl.yazi.git
|
||||
ya pack -a Reledia/hexyl
|
||||
```
|
||||
|
||||
then include it in your `yazi.toml` to use:
|
||||
@ -15,7 +15,7 @@ append_previewers = [
|
||||
]
|
||||
```
|
||||
|
||||
Make sure you have [hexyl](https://github.com/sharkdp/hexyl) installed, and can be found in `PATH`.
|
||||
Make sure you have [hexyl](https://github.com/sharkdp/hexyl) installed, and that can be found in `PATH`.
|
||||
|
||||
## Preview
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@ local M = {}
|
||||
|
||||
function M:peek()
|
||||
local child
|
||||
local l = self.file.cha.length
|
||||
local l = self.file.cha.len
|
||||
if l == 0 then
|
||||
child = Command("hexyl")
|
||||
:args({
|
||||
@ -43,13 +43,10 @@ function M:peek()
|
||||
|
||||
child:start_kill()
|
||||
if self.skip > 0 and i < self.skip + limit then
|
||||
ya.manager_emit(
|
||||
"peek",
|
||||
{ tostring(math.max(0, i - limit)), only_if = tostring(self.file.url), upper_bound = "" }
|
||||
)
|
||||
ya.manager_emit("peek", { math.max(0, i - limit), only_if = self.file.url, upper_bound = true })
|
||||
else
|
||||
lines = lines:gsub("\t", string.rep(" ", PREVIEW.tab_size))
|
||||
ya.preview_widgets(self, { ui.Paragraph.parse(self.area, lines) })
|
||||
ya.preview_widgets(self, { ui.Text.parse(lines):area(self.area) })
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@ -7,7 +7,7 @@ https://github.com/yazi-rs/plugins/assets/17523360/c4f0b5c4-ff9f-4be8-ba73-4d8e7
|
||||
## Installation
|
||||
|
||||
```sh
|
||||
ya pack -a yazi-rs/plugins#hide-preview
|
||||
ya pack -a yazi-rs/plugins:hide-preview
|
||||
```
|
||||
|
||||
## Usage
|
||||
@ -22,3 +22,20 @@ desc = "Hide or show preview"
|
||||
```
|
||||
|
||||
Make sure the <kbd>T</kbd> key is not used elsewhere.
|
||||
|
||||
## Advanced
|
||||
|
||||
In addition to triggering the plugin with a keypress, you can also trigger it in your `init.lua` file:
|
||||
|
||||
```lua
|
||||
if os.getenv("NVIM") then
|
||||
require("hide-preview"):entry()
|
||||
end
|
||||
```
|
||||
|
||||
In the example above, when it detects that you're [using Yazi in nvim](https://yazi-rs.github.io/docs/resources#vim), the
|
||||
preview is hidden by default - you can always press `T` (or any key you've bound) to display it again.
|
||||
|
||||
## License
|
||||
|
||||
This plugin is MIT-licensed. For more information check the [LICENSE](LICENSE) file.
|
||||
|
||||
@ -18,4 +18,6 @@ local function entry(st)
|
||||
ya.app_emit("resize", {})
|
||||
end
|
||||
|
||||
return { entry = entry }
|
||||
local function enabled(st) return st.old ~= nil end
|
||||
|
||||
return { entry = entry, enabled = enabled }
|
||||
|
||||
@ -7,7 +7,7 @@ https://github.com/yazi-rs/plugins/assets/17523360/8976308e-ebfe-4e9e-babe-153eb
|
||||
## Installation
|
||||
|
||||
```sh
|
||||
ya pack -a yazi-rs/plugins#max-preview
|
||||
ya pack -a yazi-rs/plugins:max-preview
|
||||
```
|
||||
|
||||
## Usage
|
||||
@ -22,3 +22,26 @@ desc = "Maximize or restore preview"
|
||||
```
|
||||
|
||||
Make sure the <kbd>T</kbd> key is not used elsewhere.
|
||||
|
||||
## Tips
|
||||
|
||||
This plugin only maximizes the "available preview area", without actually changing the content size.
|
||||
|
||||
This means that the appearance of your preview largely depends on the previewer you are using.
|
||||
However, most previewers tend to make the most of the available space, so this usually isn't an issue.
|
||||
|
||||
For image previews, you may want to tune up the [`max_width`][max-width] and [`max_height`][max-height] options in your `yazi.toml`:
|
||||
|
||||
```toml
|
||||
[preview]
|
||||
# Change them to your desired values
|
||||
max_width = 1000
|
||||
max_height = 1000
|
||||
```
|
||||
|
||||
[max-width]: https://yazi-rs.github.io/docs/configuration/yazi/#preview.max_width
|
||||
[max-height]: https://yazi-rs.github.io/docs/configuration/yazi/#preview.max_height
|
||||
|
||||
## License
|
||||
|
||||
This plugin is MIT-licensed. For more information check the [LICENSE](LICENSE) file.
|
||||
|
||||
@ -17,4 +17,6 @@ local function entry(st)
|
||||
ya.app_emit("resize", {})
|
||||
end
|
||||
|
||||
return { entry = entry }
|
||||
local function enabled(st) return st.old ~= nil end
|
||||
|
||||
return { entry = entry, enabled = enabled }
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
# miller.yazi
|
||||
|
||||
[Miller](https://github.com/johnkerl/miller) now in [yazi](https://github.com/sxyazi/yazi). To install, clone the repo inside `~/.config/yazi/plugins/`:
|
||||
[Miller](https://github.com/johnkerl/miller) now in [yazi](https://github.com/sxyazi/yazi). To install, use the command `ya pack -a Reledia/miller` and add to your `yazi.toml`:
|
||||
|
||||
```toml
|
||||
[plugin]
|
||||
@ -20,7 +20,8 @@ To change colors of keys and values, edit the `init.lua` file after the `--key-c
|
||||
## Other types of file
|
||||
|
||||
To adapt this plugin to the other format supported from miller (like json):
|
||||
|
||||
- copy the plugin folder
|
||||
- change the name of the copied folder into miller_(fmt)
|
||||
- change the name of the copied folder into miller\_(fmt)
|
||||
- change the `--icsv` flag inside `init.lua` to `--i(fmt)`
|
||||
- add the correct mime/name rule into `prepend_previewers` and the exec as `miller_(fmt)`
|
||||
|
||||
@ -8,11 +8,14 @@ View your Jupyter notebooks beautifully in the preview in Yazi.
|
||||
- [nbpreview](https://github.com/paw-lu/nbpreview)
|
||||
|
||||
## Previews
|
||||
|
||||
<img width="1416" alt="image" src="https://github.com/AnirudhG07/nbpreview.yazi/assets/146579014/87535dc9-c45a-4eb7-a732-4384460b516d">
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
ya pack -a AnirudhG07/nbpreview
|
||||
|
||||
## For linux and MacOS
|
||||
git clone https://github.com/AnirudhG07/nbpreview.yazi.git ~/.config/yazi/plugins/nbpreview.yazi
|
||||
|
||||
@ -69,4 +72,8 @@ You can change the default give color scheme and theme to any you like.
|
||||
|
||||
> [!Note]
|
||||
>
|
||||
> The loading of `ipynb` might appear slow. This is due to the lag created by the command itself and not because of the plugin or yazi
|
||||
> The loading of `ipynb` might appear slow. This is due to the lag created by the command itself and not because of the plugin or yazi
|
||||
|
||||
## Explore Yazi
|
||||
|
||||
Yazi is an amazing, blazing fast terminal file manager, with a variety of plugins, flavors and themes. Check them out at [awesome-yazi](https://github.com/AnirudhG07/awesome-yazi) and the official [yazi webpage](https://yazi-rs.github.io/).
|
||||
|
||||
@ -68,9 +68,13 @@ function M:seek(units)
|
||||
end
|
||||
|
||||
function M:fallback_to_builtin()
|
||||
local _, bound = ya.preview_code(self)
|
||||
local err, bound = ya.preview_code(self)
|
||||
if bound then
|
||||
ya.manager_emit("peek", { tostring(bound), only_if = tostring(self.file.url), upper_bound = "" })
|
||||
ya.manager_emit("peek", { bound, only_if = self.file.url, upper_bound = true })
|
||||
elseif err and not err:find("cancelled", 1, true) then
|
||||
ya.preview_widgets(self, {
|
||||
ui.Paragraph(self.area, { ui.Line(err):reverse() }),
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
21
config/yazi/plugins/ouch.yazi/LICENSE
Normal file
21
config/yazi/plugins/ouch.yazi/LICENSE
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2024 ndtoan96
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
67
config/yazi/plugins/ouch.yazi/README.md
Normal file
67
config/yazi/plugins/ouch.yazi/README.md
Normal file
@ -0,0 +1,67 @@
|
||||
# ouch.yazi
|
||||
|
||||
[ouch](https://github.com/ouch-org/ouch) plugin for [Yazi](https://github.com/sxyazi/yazi).
|
||||
|
||||

|
||||
|
||||
## Features
|
||||
- Archive preview
|
||||
- Compression
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
# Linux/macOS
|
||||
git clone https://github.com/ndtoan96/ouch.yazi.git ~/.config/yazi/plugins/ouch.yazi
|
||||
|
||||
# Windows
|
||||
git clone https://github.com/ndtoan96/ouch.yazi.git %AppData%\yazi\config\plugins\ouch.yazi
|
||||
```
|
||||
|
||||
Make sure you have [ouch](https://github.com/ouch-org/ouch) installed and in your `PATH`.
|
||||
|
||||
## Usage
|
||||
|
||||
### Preview
|
||||
For archive preview, add this to your `yazi.toml`:
|
||||
|
||||
```toml
|
||||
[plugin]
|
||||
prepend_previewers = [
|
||||
# Archive previewer
|
||||
{ mime = "application/*zip", run = "ouch" },
|
||||
{ mime = "application/x-tar", run = "ouch" },
|
||||
{ mime = "application/x-bzip2", run = "ouch" },
|
||||
{ mime = "application/x-7z-compressed", run = "ouch" },
|
||||
{ mime = "application/x-rar", run = "ouch" },
|
||||
{ mime = "application/x-xz", run = "ouch" },
|
||||
]
|
||||
```
|
||||
|
||||
Now go to an archive on Yazi, you should see the archive's content in the preview pane. You can use `Alt-j` and `Alt-k` to roll up and down the preview.
|
||||
|
||||
If you want to change the icon or the style of text, you can modify the `peek` function in `init.lua` file (all of them are stored in the `lines` variable).
|
||||
|
||||
### Compression
|
||||
For compession, add this to your `keymap.toml`:
|
||||
|
||||
```toml
|
||||
[[manager.prepend_keymap]]
|
||||
on = ["C"]
|
||||
run = "plugin ouch --args=zip"
|
||||
desc = "Compress with ouch"
|
||||
```
|
||||
|
||||
The `--args=zip` part tells the plugin that default format is `zip`. You can change that to whatever format you want.
|
||||
|
||||
### Decompression
|
||||
This plugin does not provide a decompression feature because it already is supported by Yazi.
|
||||
To decompress with `ouch`, configure the opener in `yazi.toml`.
|
||||
|
||||
```toml
|
||||
[opener]
|
||||
extract = [
|
||||
{ run = 'ouch d -y "%*"', desc = "Extract here with ouch", for = "windows" },
|
||||
{ run = 'ouch d -y "$@"', desc = "Extract here with ouch", for = "unix" },
|
||||
]
|
||||
```
|
||||
143
config/yazi/plugins/ouch.yazi/init.lua
Normal file
143
config/yazi/plugins/ouch.yazi/init.lua
Normal file
@ -0,0 +1,143 @@
|
||||
local M = {}
|
||||
|
||||
function M:peek()
|
||||
local child = Command("ouch")
|
||||
:args({ "l", "-t", "-y", tostring(self.file.url) })
|
||||
:stdout(Command.PIPED)
|
||||
:stderr(Command.PIPED)
|
||||
:spawn()
|
||||
local limit = self.area.h
|
||||
local file_name = string.match(tostring(self.file.url), ".*[/\\](.*)")
|
||||
local lines = string.format("\x1b[2m📁 %s\x1b[0m\n", file_name)
|
||||
local num_lines = 1
|
||||
local num_skip = 0
|
||||
repeat
|
||||
local line, event = child:read_line()
|
||||
if event == 1 then
|
||||
ya.err(tostring(event))
|
||||
elseif event ~= 0 then
|
||||
break
|
||||
end
|
||||
|
||||
if line:find('Archive', 1, true) ~= 1 and line:find('[INFO]', 1, true) ~= 1 then
|
||||
if num_skip >= self.skip then
|
||||
lines = lines .. line
|
||||
num_lines = num_lines + 1
|
||||
else
|
||||
num_skip = num_skip + 1
|
||||
end
|
||||
end
|
||||
until num_lines >= limit
|
||||
|
||||
child:start_kill()
|
||||
if self.skip > 0 and num_lines < limit then
|
||||
ya.manager_emit(
|
||||
"peek",
|
||||
{ tostring(math.max(0, self.skip - (limit - num_lines))), only_if = tostring(self.file.url), upper_bound = "" }
|
||||
)
|
||||
else
|
||||
ya.preview_widgets(self, { ui.Paragraph.parse(self.area, lines) })
|
||||
end
|
||||
end
|
||||
|
||||
function M:seek(units)
|
||||
local h = cx.active.current.hovered
|
||||
if h and h.url == self.file.url then
|
||||
local step = math.floor(units * self.area.h / 10)
|
||||
ya.manager_emit("peek", {
|
||||
math.max(0, cx.active.preview.skip + step),
|
||||
only_if = tostring(self.file.url),
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
-- Check if file exists
|
||||
local function file_exists(name)
|
||||
local f = io.open(name, "r")
|
||||
if f ~= nil then
|
||||
io.close(f)
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
-- Get the files that need to be compressed and infer a default archive name
|
||||
local get_compression_target = ya.sync(function()
|
||||
local tab = cx.active
|
||||
local default_name
|
||||
local paths = {}
|
||||
if #tab.selected == 0 then
|
||||
if tab.current.hovered then
|
||||
local name = tab.current.hovered.name
|
||||
default_name = name
|
||||
table.insert(paths, name)
|
||||
else
|
||||
return
|
||||
end
|
||||
else
|
||||
default_name = tab.current.cwd:name()
|
||||
for _, url in pairs(tab.selected) do
|
||||
table.insert(paths, tostring(url))
|
||||
end
|
||||
-- The compression targets are aquired, now unselect them
|
||||
ya.manager_emit("escape", {})
|
||||
end
|
||||
return paths, default_name
|
||||
end)
|
||||
|
||||
local function invoke_compress_command(paths, name)
|
||||
local cmd_output, err_code = Command("ouch")
|
||||
:args({ "c", "-y" })
|
||||
:args(paths)
|
||||
:arg(name)
|
||||
:stderr(Command.PIPED)
|
||||
:output()
|
||||
if err_code ~= nil then
|
||||
ya.notify({
|
||||
title = "Failed to run ouch command",
|
||||
content = "Status: " .. err_code,
|
||||
timeout = 5.0,
|
||||
level = "error",
|
||||
})
|
||||
elseif not cmd_output.status.success then
|
||||
ya.notify({
|
||||
title = "Compression failed: status code " .. cmd_output.status.code,
|
||||
content = cmd_output.stderr,
|
||||
timeout = 5.0,
|
||||
level = "error",
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
function M:entry(args)
|
||||
local default_fmt = args[1]
|
||||
|
||||
-- Get the files that need to be compressed and infer a default archive name
|
||||
local paths, default_name = get_compression_target()
|
||||
|
||||
-- Get archive name from user
|
||||
local output_name, name_event = ya.input({
|
||||
title = "Create archive:",
|
||||
value = default_name .. "." .. default_fmt,
|
||||
position = { "top-center", y = 3, w = 40 },
|
||||
})
|
||||
if name_event ~= 1 then
|
||||
return
|
||||
end
|
||||
|
||||
-- Get confirmation if file exists
|
||||
if file_exists(output_name) then
|
||||
local confirm, confirm_event = ya.input({
|
||||
title = "Overwrite " .. output_name .. "? (y/N)",
|
||||
position = { "top-center", y = 3, w = 40 },
|
||||
})
|
||||
if not (confirm_event == 1 and confirm:lower() == "y") then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
invoke_compress_command(paths, output_name)
|
||||
end
|
||||
|
||||
return M
|
||||
@ -6,39 +6,14 @@ https://github.com/dedukun/relative-motions.yazi/assets/25795432/04fb186a-5efe-4
|
||||
|
||||
## Requirements
|
||||
|
||||
- [Yazi](https://github.com/sxyazi/yazi) v0.2.4+
|
||||
- [Yazi](https://github.com/sxyazi/yazi) v0.3.0+
|
||||
|
||||
## Installation
|
||||
|
||||
<details>
|
||||
<summary>Yazi v0.2.5 and before (manual installation)</summary>
|
||||
|
||||
```sh
|
||||
# Linux/macOS
|
||||
git clone https://github.com/dedukun/relative-motions.yazi.git ~/.config/yazi/plugins/relative-motions.yazi
|
||||
|
||||
# Windows
|
||||
git clone https://github.com/dedukun/relative-motions.yazi.git %AppData%\yazi\config\plugins\relative-motions.yazi
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>Latest commit in Yazi (package manager)</summary>
|
||||
|
||||
```sh
|
||||
# Add the plugin
|
||||
ya pack -a dedukun/relative-motions
|
||||
|
||||
# Install plugin
|
||||
ya pack -i
|
||||
|
||||
# Update plugin
|
||||
ya pack -u
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
## Configuration
|
||||
|
||||
If you want to use the numbers directly to start a motion add this to your `keymap.toml`:
|
||||
@ -122,10 +97,10 @@ require("relative-motions"):setup({ show_numbers="relative", show_motion = true
|
||||
```
|
||||
|
||||
> [!NOTE]
|
||||
> The `show_numbers` and `show_motion` functionalities overwrite [`Current:render`](https://github.com/sxyazi/yazi/blob/e51e8ad789914b2ab4a9485da7aa7fbc7b3bb450/yazi-plugin/preset/components/current.lua#L5)
|
||||
> and [`Status:render`](https://github.com/sxyazi/yazi/blob/e51e8ad789914b2ab4a9485da7aa7fbc7b3bb450/yazi-plugin/preset/components/status.lua#L111) respectively.
|
||||
> The `show_numbers` and `show_motion` functionalities overwrite [`Current:render`](https://github.com/sxyazi/yazi/blob/43b5ae0e6cc5c8ee96462651f01d78a0d98077fc/yazi-plugin/preset/components/current.lua#L26)
|
||||
> and [`Status:children_render`](https://github.com/sxyazi/yazi/blob/43b5ae0e6cc5c8ee96462651f01d78a0d98077fc/yazi-plugin/preset/components/status.lua#L172) respectively.
|
||||
> If you have custom implementations for any of this functions
|
||||
> you can add the provided `File:number` and `Status:motion` to your implementations, just check [here](https://github.com/dedukun/relative-motions.yazi/blob/main/init.lua#L39) how we are doing things.
|
||||
> you can add the provided `Entity:number` and `Status:motion` to your implementations, just check [here](https://github.com/dedukun/relative-motions.yazi/blob/main/init.lua#L126) how we are doing things.
|
||||
|
||||
## Usage
|
||||
|
||||
|
||||
@ -34,22 +34,24 @@ local SHOW_NUMBERS_RELATIVE_ABSOLUTE = 2
|
||||
----------------- R E N D E R -----------------
|
||||
-----------------------------------------------
|
||||
|
||||
local render_motion_setup = ya.sync(function()
|
||||
local render_motion_setup = ya.sync(function(_)
|
||||
ya.render()
|
||||
|
||||
Status.motion = function() return ui.Span("") end
|
||||
|
||||
Status.render = function(self, area)
|
||||
self.area = area
|
||||
|
||||
local left = ui.Line { self:mode(), self:size(), self:name() }
|
||||
local right = ui.Line { self:motion(), self:permissions(), self:percentage(), self:position() }
|
||||
return {
|
||||
ui.Paragraph(area, { left }),
|
||||
ui.Paragraph(area, { right }):align(ui.Paragraph.RIGHT),
|
||||
table.unpack(Progress:render(area, right:width())),
|
||||
}
|
||||
Status.children_render = function(self, side)
|
||||
local lines = {}
|
||||
if side == self.RIGHT then
|
||||
lines[1] = self:motion(self)
|
||||
end
|
||||
for _, c in ipairs(side == self.RIGHT and self._right or self._left) do
|
||||
lines[#lines + 1] = (type(c[1]) == "string" and self[c[1]] or c[1])(self)
|
||||
end
|
||||
return ui.Line(lines)
|
||||
end
|
||||
|
||||
-- TODO: check why it doesn't work line this
|
||||
-- Status:children_add(Status.motion, 100, Status.RIGHT)
|
||||
end)
|
||||
|
||||
local render_motion = ya.sync(function(_, motion_num, motion_cmd)
|
||||
@ -60,7 +62,7 @@ local render_motion = ya.sync(function(_, motion_num, motion_cmd)
|
||||
return ui.Span("")
|
||||
end
|
||||
|
||||
local style = self.style()
|
||||
local style = self:style()
|
||||
|
||||
local motion_span
|
||||
if not motion_cmd then
|
||||
@ -81,7 +83,7 @@ end)
|
||||
local render_numbers = ya.sync(function(_, mode)
|
||||
ya.render()
|
||||
|
||||
File.number = function(_, index, file, hovered)
|
||||
Entity.number = function(_, index, file, hovered)
|
||||
local idx
|
||||
if mode == SHOW_NUMBERS_RELATIVE then
|
||||
idx = math.abs(hovered - index)
|
||||
@ -105,12 +107,10 @@ local render_numbers = ya.sync(function(_, mode)
|
||||
end
|
||||
end
|
||||
|
||||
Current.render = function(self, area)
|
||||
self.area = area
|
||||
|
||||
local files = Folder:by_kind(Folder.CURRENT).window
|
||||
Current.render = function(self)
|
||||
local files = self._folder.window
|
||||
if #files == 0 then
|
||||
return self:empty(area)
|
||||
return self:empty()
|
||||
end
|
||||
|
||||
local hovered_index
|
||||
@ -121,22 +121,17 @@ local render_numbers = ya.sync(function(_, mode)
|
||||
end
|
||||
end
|
||||
|
||||
local items, markers = {}, {}
|
||||
local entities, linemodes = {}, {}
|
||||
for i, f in ipairs(files) do
|
||||
items[#items + 1] = ui.ListItem(ui.Line(ya.flat { File:number(i, f, hovered_index), File:full(f) }))
|
||||
:style(File:style(f))
|
||||
linemodes[#linemodes + 1] = Linemode:new(f):render()
|
||||
|
||||
-- Yanked/marked/selected files
|
||||
local marker = File:marker(f)
|
||||
if marker ~= 0 then
|
||||
markers[#markers + 1] = { i, marker }
|
||||
end
|
||||
local entity = Entity:new(f)
|
||||
entities[#entities + 1] = ui.Line({ Entity:number(i, f, hovered_index), entity:render() }):style(entity:style())
|
||||
end
|
||||
|
||||
return ya.flat {
|
||||
ui.List(area, items),
|
||||
Folder:linemode(area, files),
|
||||
Folder:markers(area, markers),
|
||||
return {
|
||||
ui.List(entities):area(self._area),
|
||||
ui.Text(linemodes):area(self._area):align(ui.Text.RIGHT),
|
||||
}
|
||||
end
|
||||
end)
|
||||
|
||||
@ -6,19 +6,21 @@ Starship prompt plugin for [Yazi](https://github.com/sxyazi/yazi)
|
||||
|
||||
## Requirements
|
||||
|
||||
- [Yazi](https://github.com/sxyazi/yazi) v0.2.4+
|
||||
- [Yazi](https://github.com/sxyazi/yazi)
|
||||
- [starship](https://github.com/starship/starship)
|
||||
|
||||
## Installation
|
||||
|
||||
### Linux / MacOS
|
||||
|
||||
```sh
|
||||
git clone https://github.com/Rolv-Apneseth/starship.yazi.git ~/.config/yazi/plugins/starship.yazi
|
||||
```bash
|
||||
ya pack -a Rolv-Apneseth/starship
|
||||
```
|
||||
|
||||
### Windows
|
||||
### Manual
|
||||
|
||||
```sh
|
||||
# Linux / MacOS
|
||||
git clone https://github.com/Rolv-Apneseth/starship.yazi.git ~/.config/yazi/plugins/starship.yazi
|
||||
# Windows
|
||||
git clone https://github.com/Rolv-Apneseth/starship.yazi.git %AppData%\yazi\config\plugins\starship.yazi
|
||||
```
|
||||
|
||||
@ -30,60 +32,70 @@ Add this to `~/.config/yazi/init.lua`:
|
||||
require("starship"):setup()
|
||||
```
|
||||
|
||||
If you wish to define a custom config file for `starship` to use, you can pass in a path
|
||||
to the setup function like this:
|
||||
|
||||
```lua
|
||||
starship:setup({ config_file = "/home/rolv/.config/starship_secondary.toml" })
|
||||
```
|
||||
|
||||
Make sure you have [starship](https://github.com/starship/starship) installed and in your `PATH`.
|
||||
|
||||
## Extra
|
||||
|
||||
If you use a `starship` theme with a background colour, it might look a bit to cramped on just the one line `Yazi` gives the header by default. You can add some space for the header by either using the [full border tip](https://yazi-rs.github.io/docs/tips/#full-border) from the `Yazi` docs, or add this slightly modified version (which won't add in the borders) to your `init.lua`:
|
||||
If you use a `starship` theme with a background colour, it might look a bit to cramped on just the one line `Yazi` gives the header by default. To fix this, you can add this to your `init.lua`:
|
||||
|
||||
<details>
|
||||
<summary>Click to expand</summary>
|
||||
|
||||
```lua
|
||||
function Manager:render(area)
|
||||
local chunks = self:layout(area)
|
||||
|
||||
local old_build = Tab.build
|
||||
Tab.build = function(self, ...)
|
||||
local bar = function(c, x, y)
|
||||
x, y = math.max(0, x), math.max(0, y)
|
||||
if x <= 0 or x == self._area.w - 1 then
|
||||
return ui.Bar(ui.Rect.default, ui.Bar.TOP)
|
||||
end
|
||||
|
||||
return ui.Bar(
|
||||
ui.Rect({
|
||||
x = x,
|
||||
y = y,
|
||||
w = ya.clamp(0, area.w - x, 1),
|
||||
h = math.min(1, area.h),
|
||||
y = math.max(0, y),
|
||||
w = ya.clamp(0, self._area.w - x, 1),
|
||||
h = math.min(1, self._area.h),
|
||||
}),
|
||||
ui.Bar.TOP
|
||||
):symbol(c)
|
||||
end
|
||||
|
||||
return ya.flat({
|
||||
ui.Bar(chunks[1], ui.Bar.RIGHT)
|
||||
:symbol(THEME.manager.border_symbol)
|
||||
:style(THEME.manager.border_style),
|
||||
ui.Bar(chunks[3], ui.Bar.LEFT)
|
||||
:symbol(THEME.manager.border_symbol)
|
||||
:style(THEME.manager.border_style),
|
||||
local c = self._chunks
|
||||
self._chunks = {
|
||||
c[1]:padding(ui.Padding.y(1)),
|
||||
c[2]:padding(ui.Padding(c[1].w > 0 and 0 or 1, c[3].w > 0 and 0 or 1, 1, 1)),
|
||||
c[3]:padding(ui.Padding.y(1)),
|
||||
}
|
||||
|
||||
bar("┬", chunks[1].right - 1, chunks[1].y),
|
||||
bar("┴", chunks[1].right - 1, chunks[1].bottom - 1),
|
||||
bar("┬", chunks[2].right, chunks[2].y),
|
||||
bar("┴", chunks[2].right, chunks[1].bottom - 1),
|
||||
local style = THEME.manager.border_style
|
||||
self._base = ya.list_merge(self._base or {}, {
|
||||
-- Enable for full border
|
||||
--[[ ui.Border(self._area, ui.Border.ALL):type(ui.Border.ROUNDED):style(style), ]]
|
||||
ui.Bar(self._chunks[1], ui.Bar.RIGHT):style(style),
|
||||
ui.Bar(self._chunks[3], ui.Bar.LEFT):style(style),
|
||||
|
||||
-- Parent
|
||||
Parent:render(chunks[1]:padding(ui.Padding.xy(1))),
|
||||
-- Current
|
||||
Current:render(chunks[2]:padding(ui.Padding.y(1))),
|
||||
-- Preview
|
||||
Preview:render(chunks[3]:padding(ui.Padding.xy(1))),
|
||||
bar("┬", c[1].right - 1, c[1].y),
|
||||
bar("┴", c[1].right - 1, c[1].bottom - 1),
|
||||
bar("┬", c[2].right, c[2].y),
|
||||
bar("┴", c[2].right, c[1].bottom - 1),
|
||||
})
|
||||
|
||||
old_build(self, ...)
|
||||
end
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
> [!NOTE]
|
||||
> This works by overriding your `Manager:render` function so make sure this is the only place you're doing that in your config
|
||||
> This works by overriding your `Tab.build` function so make sure this is the only place you're doing that in your config. For example, this would be incompatible with the [full-border plugin](https://github.com/yazi-rs/plugins/tree/main/full-border.yazi)
|
||||
|
||||
## Acknowledgements
|
||||
## Thanks
|
||||
|
||||
- [sxyazi](https://github.com/sxyazi) for providing the code for this plugin and the demo video [in this comment](https://github.com/sxyazi/yazi/issues/767#issuecomment-1977082834)
|
||||
|
||||
@ -1,27 +1,78 @@
|
||||
local save = ya.sync(function(st, cwd, output)
|
||||
if cx.active.current.cwd == Url(cwd) then
|
||||
st.output = output
|
||||
ya.render()
|
||||
end
|
||||
if cx.active.current.cwd == Url(cwd) then
|
||||
st.output = output
|
||||
ya.render()
|
||||
end
|
||||
end)
|
||||
|
||||
-- Helper function for accessing the `config_file` state variable
|
||||
---@return string
|
||||
local get_config_file = ya.sync(function(st)
|
||||
return st.config_file
|
||||
end)
|
||||
|
||||
return {
|
||||
setup = function(st)
|
||||
Header.cwd = function()
|
||||
local cwd = cx.active.current.cwd
|
||||
if st.cwd ~= cwd then
|
||||
st.cwd = cwd
|
||||
ya.manager_emit("plugin", { st._name, args = ya.quote(tostring(cwd)) })
|
||||
end
|
||||
---User arguments for setup method
|
||||
---@class SetupArgs
|
||||
---@field config_file string Absolute path to a starship config file
|
||||
|
||||
return ui.Line.parse(st.output or "")
|
||||
end
|
||||
end,
|
||||
--- Setup plugin
|
||||
--- @param st table State
|
||||
--- @param args SetupArgs|nil
|
||||
setup = function(st, args)
|
||||
-- Replace default header widget
|
||||
Header:children_remove(1, Header.LEFT)
|
||||
Header:children_add(function()
|
||||
return ui.Line.parse(st.output or "")
|
||||
end, 1000, Header.LEFT)
|
||||
|
||||
entry = function(_, args)
|
||||
local output = Command("starship"):arg("prompt"):cwd(args[1]):env("STARSHIP_SHELL", ""):output()
|
||||
if output then
|
||||
save(args[1], output.stdout:gsub("^%s+", ""))
|
||||
end
|
||||
end,
|
||||
-- Check for custom starship config file
|
||||
if args ~= nil and args.config_file ~= nil then
|
||||
local url = Url(args.config_file)
|
||||
if url.is_regular then
|
||||
local config_file = args.config_file
|
||||
|
||||
-- Manually replace '~' and '$HOME' at the start of the path with the OS environment variable
|
||||
local home = os.getenv("HOME")
|
||||
if home then
|
||||
home = tostring(home)
|
||||
config_file = config_file:gsub("^~", home):gsub("^$HOME", home)
|
||||
end
|
||||
|
||||
st.config_file = config_file
|
||||
end
|
||||
end
|
||||
|
||||
-- Pass current working directory and custom config path (if specified) to the plugin's entry point
|
||||
---Callback for subscribers to update the prompt
|
||||
local callback = function()
|
||||
local cwd = cx.active.current.cwd
|
||||
if st.cwd ~= cwd then
|
||||
st.cwd = cwd
|
||||
ya.manager_emit("plugin", {
|
||||
st._id,
|
||||
args = ya.quote(tostring(cwd), true),
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
-- Subscribe to events
|
||||
ps.sub("cd", callback)
|
||||
ps.sub("tab", callback)
|
||||
end,
|
||||
|
||||
entry = function(_, args)
|
||||
local command = Command("starship"):arg("prompt"):cwd(args[1]):env("STARSHIP_SHELL", "")
|
||||
|
||||
-- Point to custom starship config
|
||||
local config_file = get_config_file()
|
||||
if config_file then
|
||||
command = command:env("STARSHIP_CONFIG", config_file)
|
||||
end
|
||||
|
||||
local output = command:output()
|
||||
if output then
|
||||
save(args[1], output.stdout:gsub("^%s+", ""))
|
||||
end
|
||||
end,
|
||||
}
|
||||
|
||||
21
config/yazi/plugins/what-size.yazi/LICENSE
Normal file
21
config/yazi/plugins/what-size.yazi/LICENSE
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2024 Francesco Pira
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
39
config/yazi/plugins/what-size.yazi/README.md
Normal file
39
config/yazi/plugins/what-size.yazi/README.md
Normal file
@ -0,0 +1,39 @@
|
||||
# what-size.yazi
|
||||
|
||||
A plugin for [yazi](https://github.com/sxyazi/yazi) to calculate the size of the current selection or the current working directory (if no selection is made).
|
||||
|
||||
## Requirements
|
||||
|
||||
- `du`
|
||||
|
||||
## Installation
|
||||
|
||||
```sh
|
||||
ya pack -a 'pirafrank/what-size'
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
Add this to your `~/.config/yazi/keymap.toml`:
|
||||
|
||||
```toml
|
||||
[manager]
|
||||
prepend_keymap = [
|
||||
{ on = [ ".", "s" ], run = "plugin what-size", desc = "Calc size of selection or cwd" },
|
||||
]
|
||||
```
|
||||
|
||||
If you want to copy the result to clipboard, you can add `--clipboard` or `-c` as first argument:
|
||||
|
||||
```toml
|
||||
[manager]
|
||||
prepend_keymap = [
|
||||
{ on = [ ".", "s" ], run = "plugin what-size --args='--clipboard'", desc = "Calc size of selection or cwd" },
|
||||
]
|
||||
```
|
||||
|
||||
Change to whatever keybinding you like.
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
72
config/yazi/plugins/what-size.yazi/init.lua
Normal file
72
config/yazi/plugins/what-size.yazi/init.lua
Normal file
@ -0,0 +1,72 @@
|
||||
|
||||
-- function to get paths of selected elements or current directory
|
||||
-- of no elements are selected
|
||||
local get_paths = ya.sync(function()
|
||||
local paths = {}
|
||||
-- get selected files
|
||||
for _, u in pairs(cx.active.selected) do
|
||||
paths[#paths + 1] = tostring(u)
|
||||
end
|
||||
-- if no files are selected, get current directory
|
||||
if #paths == 0 then
|
||||
if cx.active.current.cwd then
|
||||
paths[1] = tostring(cx.active.current.cwd)
|
||||
else
|
||||
ya.err("what-size would return nil paths")
|
||||
end
|
||||
end
|
||||
return paths
|
||||
end)
|
||||
|
||||
-- Function to get total size from du output
|
||||
local get_total_size = function(s)
|
||||
local lines = {}
|
||||
for line in s:gmatch("[^\n]+") do lines[#lines + 1] = line end
|
||||
local last_line = lines[#lines]
|
||||
local last_line_parts = {}
|
||||
for part in last_line:gmatch("%S+") do last_line_parts[#last_line_parts + 1] = part end
|
||||
local total_size = last_line_parts[1]
|
||||
return total_size
|
||||
end
|
||||
|
||||
-- Function to format file size
|
||||
local function format_size(size)
|
||||
local units = { "B", "KB", "MB", "GB", "TB" }
|
||||
local unit_index = 1
|
||||
|
||||
while size > 1024 and unit_index < #units do
|
||||
size = size / 1024
|
||||
unit_index = unit_index + 1
|
||||
end
|
||||
|
||||
return string.format("%.2f %s", size, units[unit_index])
|
||||
end
|
||||
|
||||
return {
|
||||
entry = function(self, args)
|
||||
-- defaults not to use clipboard, use it only if required by the user
|
||||
local clipboard = args[1] == '--clipboard' or args[1] == '-c'
|
||||
local items = get_paths()
|
||||
|
||||
local cmd = "du"
|
||||
local output, err = Command(cmd):arg("-scb"):args(items):output()
|
||||
if not output then
|
||||
ya.err("Failed to run diff, error: " .. err)
|
||||
else
|
||||
local total_size = get_total_size(output.stdout)
|
||||
local formatted_size = format_size(tonumber(total_size))
|
||||
|
||||
local notification_content = "Total size: " .. formatted_size
|
||||
if clipboard then
|
||||
ya.clipboard(formatted_size)
|
||||
notification_content = notification_content .. "\nCopied to clipboard."
|
||||
end
|
||||
|
||||
ya.notify {
|
||||
title = "What size",
|
||||
content = notification_content,
|
||||
timeout = 5,
|
||||
}
|
||||
end
|
||||
end,
|
||||
}
|
||||
@ -1,14 +1,19 @@
|
||||
# yatline.yazi
|
||||
The first Yazi plugin for customizing both header-line and status-line.
|
||||
|
||||

|
||||

|
||||

|
||||
|
||||
> [!NOTE]
|
||||
> Check out [wiki](https://github.com/imsi32/yatline.yazi/wiki) for installation steps, configuration and further information.
|
||||
|
||||
## Features
|
||||
- Lualine-like Design
|
||||
- Flexible
|
||||
- Simple
|
||||
- Automatic Configuration
|
||||
- Themes (See: [yatline-themes](https://github.com/imsi32/yatline-themes))
|
||||
- Add-ons (See: [yatline-addons](https://github.com/imsi32/yatline-addons))
|
||||
|
||||
> [!NOTE]
|
||||
> Check out [wiki](https://github.com/imsi32/yatline.yazi/wiki) for installation steps, configuration and further information.
|
||||
## Credits
|
||||
- [Lualine](https://github.com/nvim-lualine/lualine.nvim)
|
||||
- [Yazi](https://github.com/sxyazi/yazi)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -42,7 +42,10 @@ reveal = [
|
||||
{run = 'explorer /select, "%1"', orphan = true, desc = "Reveal", for = "windows"},
|
||||
{run = '''exiftool "$1"; echo "Press enter to exit"; read _''', block = true, desc = "Show EXIF", for = "unix"},
|
||||
]
|
||||
extract = [ {run = 'unar "$1"', desc = "Extract here", for = "unix"}, {run = 'unar "%1"', desc = "Extract here", for = "windows"} ]
|
||||
extract = [
|
||||
{run = 'ouch d -y "%*"', desc = "Extract here with ouch", for = "windows"},
|
||||
{run = 'ouch d -y "$@"', desc = "Extract here with ouch", for = "unix"},
|
||||
]
|
||||
play = [
|
||||
{run = 'mpv "$@"', orphan = true, for = "unix"},
|
||||
{run = 'mpv "%1"', orphan = true, for = "windows"},
|
||||
@ -87,7 +90,7 @@ previewers = [
|
||||
{mime = "text/*", run = "code"},
|
||||
{mime = "*/{xml,javascript,x-wine-extension-ini}", run = "code"},
|
||||
# JSON
|
||||
{mime = "application/json", run = "json"},
|
||||
{mime = "application/json", run = "code"},
|
||||
# Image
|
||||
{mime = "image/vnd.djvu", run = "noop"},
|
||||
{mime = "image/*", run = "image"},
|
||||
@ -95,20 +98,27 @@ previewers = [
|
||||
{mime = "video/*", run = "video"},
|
||||
# PDF
|
||||
{mime = "application/pdf", run = "pdf"},
|
||||
# Archive
|
||||
{mime = "application/*zip", run = "archive"},
|
||||
{mime = "application/x-{tar,bzip*,7z-compressed,xz,rar}", run = "archive"},
|
||||
# Fallback
|
||||
{name = "*", run = "file"},
|
||||
]
|
||||
prepend_previewers = [
|
||||
prepend_previewers = [ ]
|
||||
|
||||
append_previewers = [
|
||||
{name = "*.ipynb", run = "nbpreview"},
|
||||
{mime = "application/x-bittorrent", run = "torrent-preview"},
|
||||
{mime = "audio/*", run = "exifaudio"},
|
||||
{mime = "text/csv", run = "miller"},
|
||||
{name = "*.{md,mdx,markdown}", run = "glow"},
|
||||
# Archive previewer
|
||||
{mime = "application/*zip", run = "ouch"},
|
||||
{mime = "application/x-{tar,bzip*,7z-compressed,xz,rar}", run = "ouch"},
|
||||
{name = "*", run = "hexyl"},
|
||||
]
|
||||
|
||||
prepend_fetchers = [
|
||||
{id = "git", name = "*", run = "git"},
|
||||
{id = "git", name = "*/", run = "git"},
|
||||
]
|
||||
append_previewers = [ {name = "*", run = "hexyl"} ]
|
||||
|
||||
[input]
|
||||
# cd
|
||||
|
||||
@ -1 +1 @@
|
||||
themes/rose-pine
|
||||
themes/zathura-gruvbox-light
|
||||
@ -91,16 +91,14 @@ lfcd() {
|
||||
fi
|
||||
}
|
||||
|
||||
yazicd() {
|
||||
tmp="$(mktemp -uq)"
|
||||
trap 'rm -f $tmp >/dev/null 2>&1 && trap - HUP INT QUIT TERM PWR EXIT' HUP INT QUIT TERM PWR EXIT
|
||||
yazi "$@" --cwd-file="$tmp"
|
||||
if [ -f "$tmp" ]; then
|
||||
dir="$(cat "$tmp")"
|
||||
[ -d "$dir" ] && [ "$dir" != "$(pwd)" ] && cd "$dir" || return
|
||||
fi
|
||||
function yazicd() {
|
||||
local tmp="$(mktemp -t "yazi-cwd.XXXXXX")"
|
||||
yazi "$@" --cwd-file="$tmp"
|
||||
if cwd="$(command cat -- "$tmp")" && [ -n "$cwd" ] && [ "$cwd" != "$PWD" ]; then
|
||||
builtin cd -- "$cwd"
|
||||
fi
|
||||
rm -f -- "$tmp"
|
||||
}
|
||||
|
||||
tmux-window-name() {
|
||||
($TMUX_PLUGIN_MANAGER_PATH/tmux-window-name/scripts/rename_session_windows.py &)
|
||||
}
|
||||
|
||||
0
dotter.arm
Executable file → Normal file
0
dotter.arm
Executable file → Normal file
0
dotter.exe
Executable file → Normal file
0
dotter.exe
Executable file → Normal file
@ -1,4 +1,4 @@
|
||||
[Desktop Entry]
|
||||
Type=Application
|
||||
Name=PDF reader
|
||||
Exec=/usr/bin/zathura -e %u
|
||||
Exec=/usr/bin/zathura --fork %u
|
||||
|
||||
Loading…
Reference in New Issue
Block a user