mirror of
https://github.com/kristoferssolo/solorice.git
synced 2025-10-21 20:10:34 +00:00
Update yazi packages
This commit is contained in:
parent
f441d61eca
commit
e4d7977be1
0
config/HybridBar/scripts/change-active-workspace
Normal file → Executable file
0
config/HybridBar/scripts/change-active-workspace
Normal file → Executable file
0
config/HybridBar/scripts/get-active-workspace
Normal file → Executable file
0
config/HybridBar/scripts/get-active-workspace
Normal file → Executable file
0
config/HybridBar/scripts/get-window-title
Normal file → Executable file
0
config/HybridBar/scripts/get-window-title
Normal file → Executable file
0
config/HybridBar/scripts/get-workspaces
Normal file → Executable file
0
config/HybridBar/scripts/get-workspaces
Normal file → Executable file
@ -57,7 +57,7 @@ update_ms = 500
|
||||
|
||||
#* Processes sorting, "pid" "program" "arguments" "threads" "user" "memory" "cpu lazy" "cpu direct",
|
||||
#* "cpu lazy" sorts top process over time (easier to follow), "cpu direct" updates top process directly.
|
||||
proc_sorting = "cpu lazy"
|
||||
proc_sorting = "cpu direct"
|
||||
|
||||
#* Reverse sorting order, True or False.
|
||||
proc_reversed = False
|
||||
|
||||
0
config/eww/scripts/change-active-workspace
Normal file → Executable file
0
config/eww/scripts/change-active-workspace
Normal file → Executable file
0
config/eww/scripts/get-active-workspace
Normal file → Executable file
0
config/eww/scripts/get-active-workspace
Normal file → Executable file
0
config/eww/scripts/get-music
Normal file → Executable file
0
config/eww/scripts/get-music
Normal file → Executable file
0
config/eww/scripts/get-network
Normal file → Executable file
0
config/eww/scripts/get-network
Normal file → Executable file
0
config/eww/scripts/get-window-title
Normal file → Executable file
0
config/eww/scripts/get-window-title
Normal file → Executable file
0
config/eww/scripts/get-workspaces
Normal file → Executable file
0
config/eww/scripts/get-workspaces
Normal file → Executable file
0
config/eww/scripts/getvol
Normal file → Executable file
0
config/eww/scripts/getvol
Normal file → Executable file
0
config/eww/scripts/github
Normal file → Executable file
0
config/eww/scripts/github
Normal file → Executable file
@ -1,6 +1,6 @@
|
||||
[General]
|
||||
contrastOpacity=188
|
||||
drawColor=#ffffff
|
||||
drawColor=#ff0000
|
||||
drawThickness=3
|
||||
filenamePattern=%Y-%m-%d_%H-%M-%S
|
||||
saveAfterCopy=true
|
||||
|
||||
0
config/lf/cleaner
Normal file → Executable file
0
config/lf/cleaner
Normal file → Executable file
0
config/lf/lfrc
Normal file → Executable file
0
config/lf/lfrc
Normal file → Executable file
0
config/nsxiv/exec/image-info
Normal file → Executable file
0
config/nsxiv/exec/image-info
Normal file → Executable file
0
config/nsxiv/exec/key-handler
Normal file → Executable file
0
config/nsxiv/exec/key-handler
Normal file → Executable file
0
config/nsxiv/exec/nsxiv-url
Normal file → Executable file
0
config/nsxiv/exec/nsxiv-url
Normal file → Executable file
0
config/nsxiv/exec/thumb-info
Normal file → Executable file
0
config/nsxiv/exec/thumb-info
Normal file → Executable file
0
config/nsxiv/exec/win-title
Normal file → Executable file
0
config/nsxiv/exec/win-title
Normal file → Executable file
0
config/x11/opt-apps
Normal file → Executable file
0
config/x11/opt-apps
Normal file → Executable file
@ -5,12 +5,18 @@ require("augment-command"):setup({
|
||||
default_item_group_for_prompt = "hovered",
|
||||
smart_enter = true,
|
||||
smart_paste = false,
|
||||
smart_tab_create = false,
|
||||
smart_tab_switch = false,
|
||||
open_file_after_creation = false,
|
||||
enter_directory_after_creation = false,
|
||||
use_default_create_behaviour = false,
|
||||
enter_archives = true,
|
||||
-- extract_behaviour = "skip",
|
||||
extract_retries = 3,
|
||||
recursively_extract_archives = true,
|
||||
preserve_file_permissions = false,
|
||||
must_have_hovered_item = true,
|
||||
skip_single_subdirectory_on_enter = false,
|
||||
skip_single_subdirectory_on_leave = false,
|
||||
ignore_hidden_items = false,
|
||||
wraparound_file_navigation = false,
|
||||
})
|
||||
require("git"):setup()
|
||||
|
||||
1
config/yazi/plugins/archive.yazi/main.lua
Symbolic link
1
config/yazi/plugins/archive.yazi/main.lua
Symbolic link
@ -0,0 +1 @@
|
||||
/home/kristofers/Nextcloud/repos/solorice/config/yazi/plugins/archive.yazi/init.lua
|
||||
@ -24,6 +24,10 @@ plugin.
|
||||
- [`7z` or `7zz` command][7z-link]
|
||||
- [`file` command][file-command-link]
|
||||
|
||||
### Optional dependencies
|
||||
|
||||
- [`tar` command][gnu-tar-link] for the `preserve_file_permissions` option
|
||||
|
||||
## Installation
|
||||
|
||||
```sh
|
||||
@ -39,24 +43,25 @@ ya pack -u
|
||||
|
||||
## Configuration
|
||||
|
||||
| Configuration | Values | Default | Description |
|
||||
| ----------------------------------- | ------------------------------------- | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `prompt` | `true` or `false` | `false` | Create a prompt to choose between hovered and selected items when both exist. If this option is disabled, selected items will only be operated on when the hovered item is selected, otherwise the hovered item will be the default item that is operated on. |
|
||||
| `default_item_group_for_prompt` | `hovered`, `selected` or `none` | `hovered` | The default item group to operate on when the prompt is submitted without any value. This only takes effect if `prompt` is set to `true`, otherwise this option doesn't do anything. `hovered` means the hovered item is operated on, `selected` means the selected items are operated on, and `none` just cancels the operation. |
|
||||
| `smart_enter` | `true` or `false` | `true` | Use one command to open files or enter a directory. With this option set, the `enter` and `open` commands will both call the `enter` command when a directory is hovered and call the `open` command when a regular file is hovered. You can also enable this behaviour by passing the `--smart` flag to the `enter` or `open` commands. |
|
||||
| `smart_paste` | `true` or `false` | `false` | Paste items into a directory without entering it. The behaviour is exactly the same as the [smart paste tip on Yazi's documentation][smart-paste-tip]. Setting this option to `false` will use the default `paste` behaviour. You can also enable this behaviour by passing the `--smart` flag to the `paste` command. |
|
||||
| `smart_tab_create` | `true` or `false` | `false` | Create tabs in the directory that is being hovered instead of the current directory. The behaviour is exactly the same as the [smart tab tip on Yazi's documentation][smart-tab-tip]. Setting this option to `false` will use the default `tab_create` behaviour, which means you need to pass the `--current` flag to the command. You can also enable this behaviour by passing the `--smart` flag to the `tab_create` command. |
|
||||
| `smart_tab_switch` | `true` or `false` | `false` | If the tab that is being switched to does not exist yet, setting this option to `true` will create all the tabs in between the current number of open tabs, and the tab that is being switched to. The behaviour is exactly the same as the [smart switch tip on Yazi's documentation][smart-switch-tip]. Setting this option to `false` will use the default `tab_switch` behaviour. You can also enable this behaviour by passing the `--smart` flag to the `tab_switch` command. |
|
||||
| `open_file_after_creation` | `true` or `false` | `false` | This option determines whether the plugin will open a file after it has been created. Setting this option to `true` will cause the plugin to open the created file. You can also enable this behaviour by passing the `--open` flag to the `create` command. |
|
||||
| `enter_directory_after_creation` | `true` or `false` | `false` | This option determines whether the plugin will enter a directory after it has been created. Setting this option to `true` will cause the plugin to enter the created directory. You can also enable this behaviour by passing the `--enter` flag to the `create` command. |
|
||||
| `use_default_create_behaviour` | `true` or `false` | `false` | This option determines whether the plugin will use the behaviour of Yazi's `create` command. Setting this option to `true` will use the behaviour of Yazi's `create` command. You can also enable this behaviour by passing the `--default-behaviour` flag to the `create` command. |
|
||||
| `enter_archives` | `true` or `false` | `true` | Automatically extract and enter archive files. This option requires the [`7z` or `7zz` command][7z-link] to be present. |
|
||||
| `extract_retries` | An integer, like `1`, `3`, `10`, etc. | `3` | This option determines how many times the plugin will retry opening an encrypted or password-protected archive when a wrong password is given. This value plus 1 is the total number of times the plugin will try opening an encrypted or password-protected archive. |
|
||||
| `recursively_extract_archives` | `true` or `false` | `true` | This option determines whether the plugin will extract all archives inside an archive file recursively. If this option is set to `false`, archive files inside an archive will not be extracted, and you will have to manually extract them yourself. |
|
||||
| `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. |
|
||||
| `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. |
|
||||
| Configuration | Values | Default | Description |
|
||||
| ----------------------------------- | ------------------------------------- | --------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `prompt` | `true` or `false` | `false` | Create a prompt to choose between hovered and selected items when both exist. If this option is disabled, selected items will only be operated on when the hovered item is selected, otherwise the hovered item will be the default item that is operated on. |
|
||||
| `default_item_group_for_prompt` | `hovered`, `selected` or `none` | `hovered` | The default item group to operate on when the prompt is submitted without any value. This only takes effect if `prompt` is set to `true`, otherwise this option doesn't do anything. `hovered` means the hovered item is operated on, `selected` means the selected items are operated on, and `none` just cancels the operation. |
|
||||
| `smart_enter` | `true` or `false` | `true` | Use one command to open files or enter a directory. With this option set, the `enter` and `open` commands will both call the `enter` command when a directory is hovered and call the `open` command when a regular file is hovered. You can also enable this behaviour by passing the `--smart` flag to the `enter` or `open` commands. |
|
||||
| `smart_paste` | `true` or `false` | `false` | Paste items into a directory without entering it. The behaviour is exactly the same as the [smart paste tip on Yazi's documentation][smart-paste-tip]. Setting this option to `false` will use the default `paste` behaviour. You can also enable this behaviour by passing the `--smart` flag to the `paste` command. |
|
||||
| `smart_tab_create` | `true` or `false` | `false` | Create tabs in the directory that is being hovered instead of the current directory. The behaviour is exactly the same as the [smart tab tip on Yazi's documentation][smart-tab-tip]. Setting this option to `false` will use the default `tab_create` behaviour, which means you need to pass the `--current` flag to the command. You can also enable this behaviour by passing the `--smart` flag to the `tab_create` command. |
|
||||
| `smart_tab_switch` | `true` or `false` | `false` | If the tab that is being switched to does not exist yet, setting this option to `true` will create all the tabs in between the current number of open tabs, and the tab that is being switched to. The behaviour is exactly the same as the [smart switch tip on Yazi's documentation][smart-switch-tip]. Setting this option to `false` will use the default `tab_switch` behaviour. You can also enable this behaviour by passing the `--smart` flag to the `tab_switch` command. |
|
||||
| `open_file_after_creation` | `true` or `false` | `false` | This option determines whether the plugin will open a file after it has been created. Setting this option to `true` will cause the plugin to open the created file. You can also enable this behaviour by passing the `--open` flag to the `create` command. |
|
||||
| `enter_directory_after_creation` | `true` or `false` | `false` | This option determines whether the plugin will enter a directory after it has been created. Setting this option to `true` will cause the plugin to enter the created directory. You can also enable this behaviour by passing the `--enter` flag to the `create` command. |
|
||||
| `use_default_create_behaviour` | `true` or `false` | `false` | This option determines whether the plugin will use the behaviour of Yazi's `create` command. Setting this option to `true` will use the behaviour of Yazi's `create` command. You can also enable this behaviour by passing the `--default-behaviour` flag to the `create` command. |
|
||||
| `enter_archives` | `true` or `false` | `true` | Automatically extract and enter archive files. This option requires the [`7z` or `7zz` command][7z-link] to be present. |
|
||||
| `extract_retries` | An integer, like `1`, `3`, `10`, etc. | `3` | This option determines how many times the plugin will retry opening an encrypted or password-protected archive when a wrong password is given. This value plus 1 is the total number of times the plugin will try opening an encrypted or password-protected archive. |
|
||||
| `recursively_extract_archives` | `true` or `false` | `true` | This option determines whether the plugin will extract all archives inside an archive file recursively. If this option is set to `false`, archive files inside an archive will not be extracted, and you will have to manually extract them yourself. |
|
||||
| `preserve_file_permissions` | `true` or `false` | `false` | This option determines whether to preserve the file permissions of the items in the extracted archive. Setting this option to `true` will preserve the file permissions of the extracted items. It requires the [`tar` command][gnu-tar-link] and will only work on `tar` archives, or tarballs, as [`7z`][7z-link] does not support preserving file permissions. You will receive a warning if you have this option set but [`tar`][gnu-tar-link] is not installed. Do note that there are significant security implications of setting this option to `true`, as any executable file or binary in an archive can be immediately executed after it is extracted, which can compromise your system if you extract a malicious archive. As such, the default value is `false`, and it is strongly recommended to leave it as such. |
|
||||
| `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. |
|
||||
| `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. |
|
||||
|
||||
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`
|
||||
@ -82,6 +87,7 @@ require("augment-command"):setup({
|
||||
enter_archives = true,
|
||||
extract_retries = 3,
|
||||
recursively_extract_archives = true,
|
||||
preserve_file_permissions = false,
|
||||
must_have_hovered_item = true,
|
||||
skip_single_subdirectory_on_enter = true,
|
||||
skip_single_subdirectory_on_leave = true,
|
||||
@ -117,7 +123,7 @@ require("augment-command"):setup({
|
||||
|
||||
All commands that can operate on multiple files and directories,
|
||||
like `open`, `rename`, `remove` and `shell`,
|
||||
as well as the new commands `editor` and `pager`,
|
||||
as well as the new commands `extract`, `editor` and `pager`,
|
||||
now determine an item group to operate on.
|
||||
By default, the command will operate on the hovered item,
|
||||
unless the hovered item is also selected,
|
||||
@ -179,7 +185,98 @@ then it will operate on the selected items.
|
||||
|
||||
[open-auto-extract-archives-video]
|
||||
|
||||
- If the extracted archive file contains other archive
|
||||
- The `open` command makes use of the `extract` command,
|
||||
so recursively extracting archives is also supported.
|
||||
For more information, look at the section about the
|
||||
[`extract` command](#extract-extract).
|
||||
|
||||
Video:
|
||||
|
||||
[open-recursively-extract-archives-video]
|
||||
|
||||
### Extract (`extract`)
|
||||
|
||||
- Technically this is a new command, as Yazi does not provide an `extract`
|
||||
command. However, Yazi does provide a built-in plugin called `extract`,
|
||||
so this command is included in the
|
||||
[augmented commands section](#augmented-commands) instead of the
|
||||
[new commands section](#new-commands).
|
||||
- This command requires the [`7z` or `7zz` command][7z-link] to
|
||||
be present to extract the archives, as well as the
|
||||
[`file` command][file-command-link] to check if a file is an archive or not.
|
||||
- You are not meant to use this command directly. However, you can do so
|
||||
if you like, as the extract command is also augmented as stated in
|
||||
[this section above][augment-section].
|
||||
|
||||
Videos:
|
||||
|
||||
- When `must_have_hovered_item` is `true`:
|
||||
|
||||
[extract-must-have-hovered-item-video]
|
||||
|
||||
- When `must_have_hovered_item` is `false`:
|
||||
|
||||
[extract-hovered-item-optional-video]
|
||||
|
||||
- When `prompt` is set to `true`:
|
||||
|
||||
[extract-prompt-video]
|
||||
|
||||
- When `prompt` is set to `false`:
|
||||
|
||||
[extract-behaviour-video]
|
||||
|
||||
- Instead, this command is intended to replace the built-in `extract` plugin,
|
||||
which is used for the `extract` opener. This way, you can use the
|
||||
features that come with the augmented `extract` command, like
|
||||
recursively extracting archives, with the `open` command.
|
||||
This is the intended way to use this command, as the `open` command is
|
||||
meant to be the command that opens everything, so it is a bit
|
||||
counterintuitive to have to use a separate key to extract archives.
|
||||
|
||||
To replace the built-in `extract` plugin, copy the
|
||||
[`extract` openers section][yazi-yazi-toml-extract-openers]
|
||||
in [Yazi's default `yazi.toml`][yazi-yazi-toml] into your `yazi.toml`,
|
||||
which is located at `~/.config/yazi/yazi.toml` for Linux and macOS, and
|
||||
`C:\Users\USERNAME\AppData\Roaming\yazi\config\yazi.toml`
|
||||
file on Windows, where `USERNAME` is your Windows username.
|
||||
Make sure that the `extract` openers are under the `opener` key in your
|
||||
`yazi.toml`. Then replace `extract` with `augmented-extract`,
|
||||
and you will be using the plugin's `extract` command instead of
|
||||
Yazi's built-in `extract` plugin.
|
||||
|
||||
Here is an example configuration:
|
||||
|
||||
```toml
|
||||
# ~/.config/yazi/yazi.toml for Linux and macOS
|
||||
# C:\Users\USERNAME\AppData\Roaming\yazi\config\yazi.toml for Windows
|
||||
|
||||
[opener]
|
||||
extract = [
|
||||
{ run = 'ya pub augmented-extract --list "$@"', desc = "Extract here", for = "unix" },
|
||||
{ run = 'ya pub augmented-extract --list %*', desc = "Extract here", for = "windows" },
|
||||
]
|
||||
```
|
||||
|
||||
If that exceeds your editor's line length limit, another way to do it is:
|
||||
|
||||
```toml
|
||||
# ~/.config/yazi/yazi.toml for Linux and macOS
|
||||
# C:\Users\USERNAME\AppData\Roaming\yazi\config\yazi.toml for Windows
|
||||
|
||||
[[opener.extract]]
|
||||
run = 'ya pub augmented-extract --list "$@"'
|
||||
desc = "Extract here"
|
||||
for = "unix"
|
||||
|
||||
[[opener.extract]]
|
||||
run = 'ya pub augmented-extract --list %*'
|
||||
desc = "Extract here"
|
||||
for = "windows"
|
||||
```
|
||||
|
||||
- The `extract` command supports recursively extracting archives,
|
||||
which means if the extracted archive file contains other archive
|
||||
files in it, those archives will be automatically
|
||||
extracted, keeping the directory structure
|
||||
of the archive if the archive doesn't
|
||||
@ -198,7 +295,51 @@ then it will operate on the selected items.
|
||||
|
||||
Video:
|
||||
|
||||
[open-recursively-extract-archives-video]
|
||||
[extract-recursively-extract-archives-video]
|
||||
|
||||
- The `extract` command also supports extracting encrypted archives,
|
||||
and will prompt you for a password when it encounters an encrypted
|
||||
archive. You can configure the number of times the plugin prompts
|
||||
you for a password by setting the `extract_retries` configuration
|
||||
option. The default value is `3`, which means the plugin will
|
||||
prompt you `3` more times for the correct password after the
|
||||
initial password attempt before giving up and showing an error.
|
||||
|
||||
Video:
|
||||
|
||||
[extract-encrypted-archive]
|
||||
|
||||
- The `preserve_file_permissions` configuration option applies to
|
||||
the `extract` command, and requires the [`tar` command][gnu-tar-link]
|
||||
to be present, as [`7z`][7z-link] does not support preserving
|
||||
file permissions. The plugin will show a warning if the
|
||||
`preserve_file_permissions` option is set to `true` but
|
||||
[`tar`][gnu-tar-link] is not installed.
|
||||
|
||||
For macOS users, it is highly recommended to install and use
|
||||
[GNU `tar`, or `gtar`][gnu-tar-link] instead of the
|
||||
[Apple provided `tar` command][apple-tar-link].
|
||||
You can install it using the [`brew`][brew-link] command below:
|
||||
|
||||
```sh
|
||||
brew install gnu-tar
|
||||
```
|
||||
|
||||
The plugin will automatically use [GNU `tar`][gnu-tar-link]
|
||||
if it finds the [`gtar` command][gnu-tar-link] instead
|
||||
of the [Apple provided `tar` command][apple-tar-link].
|
||||
|
||||
Setting the `preserve_file_permissions` configuration option to `true`
|
||||
will preserve the file permissions of the files contained in a `tar`
|
||||
archive or tarball.
|
||||
|
||||
This has considerable security implications, as executables extracted from
|
||||
all `tar` archives can be immediately executed on your system, possibly
|
||||
compromising your system if you extract a malicious `tar` archive.
|
||||
Hence, this option is set to `false` by default, and should be left as such.
|
||||
This option is provided for your convenience, but do seriously consider
|
||||
if such convenience is worth the risk of extracting a malicious `tar`
|
||||
archive that executes malware on your system.
|
||||
|
||||
### Enter (`enter`)
|
||||
|
||||
@ -347,7 +488,7 @@ then it will operate on the selected items.
|
||||
|
||||
Video:
|
||||
|
||||
[create-and-open-directories-video]
|
||||
[create-and-enter-directories-video]
|
||||
|
||||
To enable both behaviours with flags, just pass both the `--open` flag
|
||||
and the `--enter` flag to the `create` command.
|
||||
@ -732,10 +873,18 @@ then add `plugin augment-command --args=`
|
||||
in front of it, which results in
|
||||
`plugin augment-command --args='enter'`.
|
||||
|
||||
### Using the `extract` command as an opener
|
||||
|
||||
This is the intended way to use the `extract` command instead of binding
|
||||
the `extract` command to a key in your `keymap.toml` file.
|
||||
Look at the [`extract` command section](#extract-extract)
|
||||
for details on how to do so.
|
||||
|
||||
### Full configuration example
|
||||
|
||||
For a full configuration example,
|
||||
you can take a look at [my `keymap.toml` file][my-keymap-toml].
|
||||
you can take a look at [my `keymap.toml` file][my-keymap-toml]
|
||||
and [my `yazi.toml` file][my-yazi-toml].
|
||||
|
||||
## [Licence]
|
||||
|
||||
@ -751,89 +900,104 @@ You can view the full licence in the [`LICENSE`][Licence] file.
|
||||
[augment-section]: #what-about-the-commands-are-augmented
|
||||
[7z-link]: https://www.7-zip.org/
|
||||
[file-command-link]: https://www.darwinsys.com/file/
|
||||
[my-keymap-toml]: https://github.com/hankertrix/Dotfiles/blob/main/.config/yazi/keymap.toml
|
||||
[gnu-tar-link]: https://www.gnu.org/software/tar/
|
||||
[apple-tar-link]: https://ss64.com/mac/tar.html
|
||||
[brew-link]: https://brew.sh/
|
||||
[yazi-yazi-toml-extract-openers]: https://github.com/sxyazi/yazi/blob/main/yazi-config/preset/yazi-default.toml#L51-L54
|
||||
[yazi-yazi-toml]: https://github.com/sxyazi/yazi/blob/main/yazi-config/preset/yazi-default.toml
|
||||
[yazi-keymap-toml]: https://github.com/sxyazi/yazi/blob/main/yazi-config/preset/keymap-default.toml
|
||||
[my-keymap-toml]: https://github.com/hankertrix/Dotfiles/blob/main/.config/yazi/keymap.toml
|
||||
[my-yazi-toml]: https://github.com/hankertrix/Dotfiles/blob/main/.config/yazi/yazi.toml
|
||||
[Licence]: LICENSE
|
||||
|
||||
<!-- Videos -->
|
||||
|
||||
<!-- Open command -->
|
||||
|
||||
[open-behaviour-video]: https://github.com/user-attachments/assets/5636ffc0-fe24-4da3-9f0e-98de9cd74096
|
||||
[open-prompt-video]: https://github.com/user-attachments/assets/6bad5a20-e5d3-491d-9c7c-0f5962b77c1c
|
||||
[open-auto-extract-archives-video]: https://github.com/user-attachments/assets/aeb3368b-4f7d-431e-9f7a-69a443af7153
|
||||
[open-recursively-extract-archives-video]: https://github.com/user-attachments/assets/44228646-3e82-41e4-a445-f93ab5649309
|
||||
[open-prompt-video]: https://github.com/user-attachments/assets/82ddc67d-0b79-4487-8d29-6fd1eb754a8e
|
||||
[open-behaviour-video]: https://github.com/user-attachments/assets/3f8eec80-ae39-4071-b7ed-e9e9367f10fe
|
||||
[open-auto-extract-archives-video]: https://github.com/user-attachments/assets/35b356ed-9c3f-4093-ab59-f85ae64de757
|
||||
[open-recursively-extract-archives-video]: https://github.com/user-attachments/assets/dd1a5bd4-c7af-4d0a-9bf5-b087ee5a06f0
|
||||
|
||||
<!-- Extract command -->
|
||||
|
||||
[extract-must-have-hovered-item-video]: https://github.com/user-attachments/assets/7c0516ff-01fd-48c2-ba27-4449ffede933
|
||||
[extract-hovered-item-optional-video]: https://github.com/user-attachments/assets/07ef7d25-3284-4d93-9485-c8635519c57e
|
||||
[extract-prompt-video]: https://github.com/user-attachments/assets/be2cabc3-b47d-4aac-ac45-0f26957c606b
|
||||
[extract-behaviour-video]: https://github.com/user-attachments/assets/6ea90612-da8f-45ad-8310-9b38c9e5a6f9
|
||||
[extract-recursively-extract-archives-video]: https://github.com/user-attachments/assets/bbf7f670-f86d-4aa4-85c7-35b41170924e
|
||||
[extract-encrypted-archive]: https://github.com/user-attachments/assets/58645691-3559-44ad-918e-8c2cd127252f
|
||||
|
||||
<!-- Enter command -->
|
||||
|
||||
[smart-enter-video]: https://github.com/user-attachments/assets/d3507110-1385-4029-bf64-da3225446d72
|
||||
[enter-skip-single-subdirectory-video]: https://github.com/user-attachments/assets/2cdb9289-ef41-454f-817b-81beb8a8d030
|
||||
[smart-enter-video]: https://github.com/user-attachments/assets/a00da3f5-305a-4615-b55c-483a06dd56d7
|
||||
[enter-skip-single-subdirectory-video]: https://github.com/user-attachments/assets/25ca5fb5-68f9-45fe-bf32-369e9335505d
|
||||
|
||||
<!-- Leave command -->
|
||||
|
||||
[leave-skip-single-subdirectory-video]: https://github.com/user-attachments/assets/49acdddb-4d04-4624-8d29-057ada33fd01
|
||||
[leave-skip-single-subdirectory-video]: https://github.com/user-attachments/assets/4740fdae-2cd9-463d-b67b-7cdfd8d8b9a1
|
||||
|
||||
<!-- Rename command -->
|
||||
|
||||
[rename-hovered-item-optional-video]: https://github.com/user-attachments/assets/3f592893-cda6-4759-ae32-3059f0c285f0
|
||||
[rename-must-have-hovered-item-video]: https://github.com/user-attachments/assets/074c6713-60e8-4249-867f-926ac6ee2bd6
|
||||
[rename-behaviour-video]: https://github.com/user-attachments/assets/ba6c79e0-9062-43ae-a76b-2782f28a9a18
|
||||
[rename-prompt-video]: https://github.com/user-attachments/assets/4d42653e-9595-4322-b0c9-451b112dc596
|
||||
[rename-must-have-hovered-item-video]: https://github.com/user-attachments/assets/fd88a198-3de3-4d2b-8bcf-8d68142c965f
|
||||
[rename-hovered-item-optional-video]: https://github.com/user-attachments/assets/324dcd94-6f83-49a2-9390-5f41da520689
|
||||
[rename-prompt-video]: https://github.com/user-attachments/assets/5aba29ae-8b16-4b92-a99c-ff7f0ec925fa
|
||||
[rename-behaviour-video]: https://github.com/user-attachments/assets/280db6dd-10e4-4255-8c12-e13d23105e90
|
||||
|
||||
<!-- Remove command -->
|
||||
|
||||
[remove-hovered-item-optional-video]: https://github.com/user-attachments/assets/dd033b80-b8b0-46db-ab02-9fc1f1b7002d
|
||||
[remove-must-have-hovered-item-video]: https://github.com/user-attachments/assets/5533b8b6-a966-4453-a86a-09d2ab2340e9
|
||||
[remove-behaviour-video]: https://github.com/user-attachments/assets/cc0617b1-fedf-45d3-b894-00524ba31434
|
||||
[remove-prompt-video]: https://github.com/user-attachments/assets/d23283fd-5068-429d-b06d-72b0c6a3bb36
|
||||
[remove-must-have-hovered-item-video]: https://github.com/user-attachments/assets/18649ff1-ef0d-409a-8f01-29431dcc8f2e
|
||||
[remove-hovered-item-optional-video]: https://github.com/user-attachments/assets/6e9f5ca0-9b9f-47f8-8499-2b2c1db9f47c
|
||||
[remove-prompt-video]: https://github.com/user-attachments/assets/3f94c6f8-2ffd-4970-a5a4-5ac6b3a621c0
|
||||
[remove-behaviour-video]: https://github.com/user-attachments/assets/37d3c059-84ff-4475-908b-2c167b23c488
|
||||
|
||||
<!-- Create command -->
|
||||
|
||||
[create-and-open-directories-video]: https://github.com/user-attachments/assets/52b244db-50a8-4adc-912f-239e01a10cc6
|
||||
[create-and-open-files-video]: https://github.com/user-attachments/assets/8f2306ea-b795-4da4-9867-9a5ed34f7e12
|
||||
[create-and-open-files-and-directories-video]: https://github.com/user-attachments/assets/ed14e451-a8ca-4622-949f-1469e1d17643
|
||||
[create-behaviour-video]: https://github.com/user-attachments/assets/0bee02b7-f0c3-4b24-8e8d-43c9d3ada3d6
|
||||
[create-default-behaviour-video]: https://github.com/user-attachments/assets/8c59f579-8f32-443c-8ae1-edd8d18e5ba0
|
||||
[create-and-enter-directories-video]: https://github.com/user-attachments/assets/a102f918-8d99-491f-a6e3-fd8151f16f96
|
||||
[create-and-open-files-video]: https://github.com/user-attachments/assets/14341b9b-a048-4ea2-9322-e963293b6813
|
||||
[create-and-open-files-and-directories-video]: https://github.com/user-attachments/assets/dd05d84a-716b-4c4b-8e77-429bbfb4ea43
|
||||
[create-behaviour-video]: https://github.com/user-attachments/assets/a13745a5-a2cc-4c25-a3ff-0f10ac98b6f9
|
||||
[create-default-behaviour-video]: https://github.com/user-attachments/assets/5e9305c0-e56c-4fc3-b36b-e86c43571b06
|
||||
|
||||
<!-- Shell command -->
|
||||
|
||||
[shell-hovered-item-optional-video]: https://github.com/user-attachments/assets/db4b0a30-0cbb-4747-9788-2fb2f8857449
|
||||
[shell-must-have-hovered-item-video]: https://github.com/user-attachments/assets/f7699493-99e7-4926-92c7-8811d3428cd4
|
||||
[shell-behaviour-video]: https://github.com/user-attachments/assets/5d898205-e5ca-487e-b731-4624ca0123ee
|
||||
[shell-prompt-video]: https://github.com/user-attachments/assets/d1790105-1e40-4639-bf65-d395a488ae94
|
||||
[shell-exit-if-directory-video]: https://github.com/user-attachments/assets/a992300a-2eed-40a1-97e4-d4efef57f7f0
|
||||
[shell-must-have-hovered-item-video]: https://github.com/user-attachments/assets/43404049-1a4c-458c-b33f-c221dddf15c6
|
||||
[shell-hovered-item-optional-video]: https://github.com/user-attachments/assets/b399450a-eec4-43d5-a75d-91c4f04a9d59
|
||||
[shell-prompt-video]: https://github.com/user-attachments/assets/e83eb468-96fd-463f-a96a-54ac9ee2295f
|
||||
[shell-behaviour-video]: https://github.com/user-attachments/assets/caa32923-9c3e-4ea4-a1b6-e0a2c7968e9d
|
||||
[shell-exit-if-directory-video]: https://github.com/user-attachments/assets/a0feab97-b7fc-4d58-8611-60ccf5e794d5
|
||||
|
||||
<!-- Paste command -->
|
||||
|
||||
[smart-paste-video]: https://github.com/user-attachments/assets/9796fbf1-6807-4f74-a0eb-a36c6306c761
|
||||
[smart-paste-video]: https://github.com/user-attachments/assets/d48c12a7-f652-4df7-90a5-271cbfa97683
|
||||
|
||||
<!-- Tab create command -->
|
||||
|
||||
[smart-tab-create-video]: https://github.com/user-attachments/assets/2738598c-ccdf-49e4-9d57-90a6378f6155
|
||||
[smart-tab-create-video]: https://github.com/user-attachments/assets/2921df3d-b51d-4dbb-a42f-80e021feaaf6
|
||||
|
||||
<!-- Tab switch command -->
|
||||
|
||||
[smart-tab-switch-video]: https://github.com/user-attachments/assets/78240347-7d5e-4b45-85df-8446cfb61edf
|
||||
[smart-tab-switch-video]: https://github.com/user-attachments/assets/1afb540d-47a9-4625-ae59-95d5cd91aa35
|
||||
|
||||
<!-- Arrow command -->
|
||||
|
||||
[wraparound-arrow-video]: https://github.com/user-attachments/assets/28d96bb3-276d-41c8-aa17-eebd7fde9390
|
||||
[wraparound-arrow-video]: https://github.com/user-attachments/assets/41ea1fb0-a526-4549-95a2-547c3c4b0498
|
||||
|
||||
<!-- Parent arrow command -->
|
||||
|
||||
[parent-arrow-video]: https://github.com/user-attachments/assets/d58a841d-0c05-4555-bf1b-f4d539b9d9c9
|
||||
[wraparound-parent-arrow-video]: https://github.com/user-attachments/assets/72dcd01a-63f0-4193-9a23-cefa61142d73
|
||||
[parent-arrow-video]: https://github.com/user-attachments/assets/f4dc492a-566b-4645-82e1-301713cff11f
|
||||
[wraparound-parent-arrow-video]: https://github.com/user-attachments/assets/d19872f8-2851-47e6-8485-4e8e5be66871
|
||||
|
||||
<!-- Editor command -->
|
||||
|
||||
[editor-hovered-item-optional-video]: https://github.com/user-attachments/assets/97e7f313-afcd-4619-bdec-539ffa0ce9a4
|
||||
[editor-must-have-hovered-item-video]: https://github.com/user-attachments/assets/4fb901d2-9a86-44ec-9896-453f6df16ea1
|
||||
[editor-behaviour-video]: https://github.com/user-attachments/assets/af057282-8f75-4662-8b4b-29e594cf4163
|
||||
[editor-prompt-video]: https://github.com/user-attachments/assets/6c12380c-36fb-4a57-bd82-8452fdcad7e6
|
||||
[editor-must-have-hovered-item-video]: https://github.com/user-attachments/assets/c2811b90-e164-4a6d-9f3d-aefe8aec1d95
|
||||
[editor-hovered-item-optional-video]: https://github.com/user-attachments/assets/adad538a-fbe8-4ad3-8f6d-5600618a0673
|
||||
[editor-prompt-video]: https://github.com/user-attachments/assets/cccb8a3c-6afa-49a6-8808-04b0f235b391
|
||||
[editor-behaviour-video]: https://github.com/user-attachments/assets/b6821220-8530-4fd1-a40f-53d191a3fe1b
|
||||
|
||||
<!-- Pager command -->
|
||||
|
||||
[pager-hovered-item-optional-video]: https://github.com/user-attachments/assets/e63af138-b553-4598-b6da-c7e3de57f328
|
||||
[pager-must-have-hovered-item-video]: https://github.com/user-attachments/assets/aa9e27e0-39ed-466f-ae84-812c08d93293
|
||||
[pager-behaviour-video]: https://github.com/user-attachments/assets/d18aec12-8be3-483a-a24a-2929ad8fc6c2
|
||||
[pager-prompt-video]: https://github.com/user-attachments/assets/ac3cd3b3-2624-4ea2-b22d-5ab6a49a98c6
|
||||
[pager-must-have-hovered-item-video]: https://github.com/user-attachments/assets/22a5211a-89cc-4c36-aadb-eb9e6ab1d578
|
||||
[pager-hovered-item-optional-video]: https://github.com/user-attachments/assets/6eaed3c9-91f4-4414-8d26-5eaf955a2861
|
||||
[pager-prompt-video]: https://github.com/user-attachments/assets/1ee621f4-704e-4cc3-a2ff-ba06e4eaf5a3
|
||||
[pager-behaviour-video]: https://github.com/user-attachments/assets/9ed0d520-4e73-44c3-82f7-18378994e0f4
|
||||
|
||||
3595
config/yazi/plugins/augment-command.yazi/main.lua
Normal file
3595
config/yazi/plugins/augment-command.yazi/main.lua
Normal file
File diff suppressed because it is too large
Load Diff
39
config/yazi/plugins/chmod.yazi/main.lua
Normal file
39
config/yazi/plugins/chmod.yazi/main.lua
Normal file
@ -0,0 +1,39 @@
|
||||
local selected_or_hovered = ya.sync(function()
|
||||
local tab, paths = cx.active, {}
|
||||
for _, u in pairs(tab.selected) do
|
||||
paths[#paths + 1] = tostring(u)
|
||||
end
|
||||
if #paths == 0 and tab.current.hovered then
|
||||
paths[1] = tostring(tab.current.hovered.url)
|
||||
end
|
||||
return paths
|
||||
end)
|
||||
|
||||
return {
|
||||
entry = function()
|
||||
ya.manager_emit("escape", { visual = true })
|
||||
|
||||
local urls = selected_or_hovered()
|
||||
if #urls == 0 then
|
||||
return ya.notify { title = "Chmod", content = "No file selected", level = "warn", timeout = 5 }
|
||||
end
|
||||
|
||||
local value, event = ya.input {
|
||||
title = "Chmod:",
|
||||
position = { "top-center", y = 3, w = 40 },
|
||||
}
|
||||
if event ~= 1 then
|
||||
return
|
||||
end
|
||||
|
||||
local status, err = Command("chmod"):arg(value):args(urls):spawn():wait()
|
||||
if not status or not status.success then
|
||||
ya.notify {
|
||||
title = "Chmod",
|
||||
content = string.format("Chmod on selected files failed, error: %s", status and status.code or err),
|
||||
level = "error",
|
||||
timeout = 5,
|
||||
}
|
||||
end
|
||||
end,
|
||||
}
|
||||
231
config/yazi/plugins/exifaudio.yazi/main.lua
Normal file
231
config/yazi/plugins/exifaudio.yazi/main.lua
Normal file
@ -0,0 +1,231 @@
|
||||
local M = {}
|
||||
|
||||
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",
|
||||
"-TitleSort", "-TitleSortOrder", "-Artist",
|
||||
"-SortArtist", "-ArtistSort", "-PerformerSortOrder",
|
||||
"-Album", "-SortAlbum", "-AlbumSort", "-AlbumSortOrder",
|
||||
"-AlbumArtist", "-SortAlbumArtist", "-AlbumArtistSort",
|
||||
"-AlbumArtistSortOrder", "-Genre", "-TrackNumber",
|
||||
"-Year", "-Duration", "-SampleRate",
|
||||
"-AudioSampleRate", "-AudioBitrate", "-AvgBitrate",
|
||||
"-Channels", "-AudioChannels", tostring(...),
|
||||
})
|
||||
:stdout(Command.PIPED)
|
||||
:stderr(Command.NULL)
|
||||
: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(job)
|
||||
local cache = ya.file_cache(job)
|
||||
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
|
||||
local status, child = pcall(Mediainfo, job.file.url, cache_dir)
|
||||
if not status or child == nil then
|
||||
status, child = pcall(Exiftool, job.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(job.area, { error }):wrap(ui.Paragraph.WRAP)
|
||||
ya.preview_widgets(job, { p })
|
||||
end
|
||||
local function display_error()
|
||||
local p = ui.Text(error):area(job.area):wrap(ui.Text.WRAP)
|
||||
ya.preview_widgets(job, { p })
|
||||
end
|
||||
if pcall(display_error) then else pcall(display_error_legacy) end
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
local limit = job.area.h
|
||||
local i, metadata = 0, {}
|
||||
repeat
|
||||
local next, event = child:read_line()
|
||||
if event == 1 then
|
||||
return self:fallback_to_builtin()
|
||||
elseif event ~= 0 then
|
||||
break
|
||||
end
|
||||
|
||||
i = i + 1
|
||||
if i > job.skip then
|
||||
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 >= job.skip + limit
|
||||
|
||||
-- TODO)) Remove legacy method when v0.4 gets released
|
||||
local function display_metadata_legacy()
|
||||
local p = ui.Paragraph(job.area, metadata):wrap(ui.Paragraph.WRAP)
|
||||
ya.preview_widgets(job, { p })
|
||||
end
|
||||
local function display_metadata()
|
||||
local p = ui.Text(metadata):area(job.area):wrap(ui.Text.WRAP)
|
||||
ya.preview_widgets(job, { p })
|
||||
end
|
||||
if pcall(display_metadata) then else pcall(display_metadata_legacy) end
|
||||
|
||||
local cover_width = job.area.w / 2 - 5
|
||||
local cover_height = (job.area.h / 4) + 3
|
||||
|
||||
local bottom_right = ui.Rect {
|
||||
x = job.area.right - cover_width,
|
||||
y = job.area.bottom - cover_height,
|
||||
w = cover_width,
|
||||
h = cover_height,
|
||||
}
|
||||
|
||||
if self:preload(job) == 1 then
|
||||
ya.image_show(cache, bottom_right)
|
||||
end
|
||||
end
|
||||
|
||||
function Prettify(metadata)
|
||||
local substitutions = {
|
||||
Sortname = "Sort Title:",
|
||||
SortName = "Sort Title:",
|
||||
TitleSort = "Sort Title:",
|
||||
TitleSortOrder = "Sort Title:",
|
||||
ArtistSort = "Sort Artist:",
|
||||
SortArtist = "Sort Artist:",
|
||||
Artist = "Artist:",
|
||||
ARTIST = "Artist:",
|
||||
PerformerSortOrder = "Sort Artist:",
|
||||
SortAlbumArtist = "Sort Album Artist:",
|
||||
AlbumArtistSortOrder = "Sort Album Artist:",
|
||||
AlbumArtistSort = "Sort Album Artist:",
|
||||
AlbumSortOrder = "Sort Album:",
|
||||
AlbumSort = "Sort Album:",
|
||||
SortAlbum = "Sort Album:",
|
||||
Album = "Album:",
|
||||
ALBUM = "Album:",
|
||||
AlbumArtist = "Album Artist:",
|
||||
Genre = "Genre:",
|
||||
GENRE = "Genre:",
|
||||
TrackNumber = "Track Number:",
|
||||
Year = "Year:",
|
||||
Duration = "Duration:",
|
||||
AudioBitrate = "Bitrate:",
|
||||
AvgBitrate = "Average Bitrate:",
|
||||
AudioSampleRate = "Sample Rate:",
|
||||
SampleRate = "Sample Rate:",
|
||||
AudioChannels = "Channels:"
|
||||
}
|
||||
|
||||
for k, v in pairs(substitutions) do
|
||||
metadata = metadata:gsub(tostring(k)..":", v, 1)
|
||||
end
|
||||
|
||||
-- Separate the tag title from the tag data
|
||||
local t={}
|
||||
for str in string.gmatch(metadata , "([^"..":".."]+)") do
|
||||
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
|
||||
local title, tag_data = "", ""
|
||||
if t[1] ~= nil then
|
||||
title, tag_data = t[1]..":", table.concat(t, ":", 2)
|
||||
end
|
||||
return title, tag_data
|
||||
|
||||
end
|
||||
|
||||
function M:seek(job)
|
||||
local h = cx.active.current.hovered
|
||||
if h and h.url == job.file.url then
|
||||
ya.manager_emit("peek", {
|
||||
tostring(math.max(0, cx.active.preview.skip + job.units)),
|
||||
only_if = tostring(job.file.url),
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
function M:preload(job)
|
||||
local cache = ya.file_cache(job)
|
||||
if not cache or fs.cha(cache) then
|
||||
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(job.file.url) })
|
||||
:stdout(Command.PIPED)
|
||||
:stderr(Command.PIPED)
|
||||
:output()
|
||||
|
||||
if not output then
|
||||
return 0
|
||||
end
|
||||
|
||||
return fs.write(cache, output.stdout) and 1 or 2
|
||||
end
|
||||
|
||||
return M
|
||||
41
config/yazi/plugins/full-border.yazi/main.lua
Normal file
41
config/yazi/plugins/full-border.yazi/main.lua
Normal file
@ -0,0 +1,41 @@
|
||||
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.Bar.TOP)
|
||||
end
|
||||
|
||||
return ui.Bar(ui.Bar.TOP)
|
||||
:area(
|
||||
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) }
|
||||
)
|
||||
:symbol(c)
|
||||
end
|
||||
|
||||
local c = self._chunks
|
||||
self._chunks = {
|
||||
c[1]:pad(ui.Pad.y(1)),
|
||||
c[2]:pad(ui.Pad(1, c[3].w > 0 and 0 or 1, 1, c[1].w > 0 and 0 or 1)),
|
||||
c[3]:pad(ui.Pad.y(1)),
|
||||
}
|
||||
|
||||
local style = THEME.manager.border_style
|
||||
self._base = ya.list_merge(self._base or {}, {
|
||||
ui.Border(ui.Border.ALL):area(self._area):type(type):style(style),
|
||||
ui.Bar(ui.Bar.RIGHT):area(self._chunks[1]):style(style),
|
||||
ui.Bar(ui.Bar.LEFT):area(self._chunks[3]):style(style),
|
||||
|
||||
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[2].bottom - 1),
|
||||
})
|
||||
|
||||
old_build(self, ...)
|
||||
end
|
||||
end
|
||||
|
||||
return { setup = setup }
|
||||
208
config/yazi/plugins/git.yazi/main.lua
Normal file
208
config/yazi/plugins/git.yazi/main.lua
Normal file
@ -0,0 +1,208 @@
|
||||
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)
|
||||
local is_worktree = function(url)
|
||||
local file, head = io.open(tostring(url)), nil
|
||||
if file then
|
||||
head = file:read(8)
|
||||
file:close()
|
||||
end
|
||||
return head == "gitdir: "
|
||||
end
|
||||
|
||||
repeat
|
||||
local next = cwd:join(".git")
|
||||
local cha = fs.cha(next)
|
||||
if cha and (cha.is_dir or is_worktree(next)) 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(_, job)
|
||||
local cwd = job.files[1].url:parent()
|
||||
local repo = root(cwd)
|
||||
if not repo then
|
||||
remove(tostring(cwd))
|
||||
return 1
|
||||
end
|
||||
|
||||
local paths = {}
|
||||
for _, f in ipairs(job.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: " .. 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 job.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 }
|
||||
76
config/yazi/plugins/glow.yazi/main.lua
Normal file
76
config/yazi/plugins/glow.yazi/main.lua
Normal file
@ -0,0 +1,76 @@
|
||||
local M = {}
|
||||
|
||||
function M:peek(job)
|
||||
-- Set a fixed width of 55 characters for the preview
|
||||
local preview_width = 55
|
||||
|
||||
local child = Command("glow")
|
||||
:args({
|
||||
"--style",
|
||||
"dark",
|
||||
"--width",
|
||||
tostring(preview_width), -- Use fixed width instead of job.area.w
|
||||
tostring(job.file.url),
|
||||
})
|
||||
:env("CLICOLOR_FORCE", "1")
|
||||
:stdout(Command.PIPED)
|
||||
:stderr(Command.PIPED)
|
||||
:spawn()
|
||||
|
||||
if not child then
|
||||
return require("code").peek(job)
|
||||
end
|
||||
|
||||
local limit = job.area.h
|
||||
local i, lines = 0, ""
|
||||
repeat
|
||||
local next, event = child:read_line()
|
||||
if event == 1 then
|
||||
return require("code").peek(job)
|
||||
elseif event ~= 0 then
|
||||
break
|
||||
end
|
||||
|
||||
i = i + 1
|
||||
if i > job.skip then
|
||||
lines = lines .. next
|
||||
end
|
||||
until i >= job.skip + limit
|
||||
|
||||
child:start_kill()
|
||||
if job.skip > 0 and i < job.skip + limit then
|
||||
ya.manager_emit("peek", {
|
||||
tostring(math.max(0, i - limit)),
|
||||
only_if = job.file.url,
|
||||
upper_bound = true
|
||||
})
|
||||
else
|
||||
lines = lines:gsub("\t", string.rep(" ", PREVIEW.tab_size))
|
||||
ya.preview_widgets(job, { ui.Text.parse(lines):area(job.area) })
|
||||
end
|
||||
end
|
||||
|
||||
function M:seek(job)
|
||||
local h = cx.active.current.hovered
|
||||
if not h or h.url ~= job.file.url then
|
||||
return
|
||||
end
|
||||
|
||||
local scroll_amount = 1
|
||||
local scroll_offset = job.units
|
||||
|
||||
if job.key == "ctrl-e" then
|
||||
scroll_offset = scroll_amount
|
||||
elseif job.key == "ctrl-y" then
|
||||
scroll_offset = -scroll_amount
|
||||
else
|
||||
scroll_offset = job.units
|
||||
end
|
||||
|
||||
ya.manager_emit('peek', {
|
||||
math.max(0, cx.active.preview.skip + scroll_offset),
|
||||
only_if = job.file.url,
|
||||
})
|
||||
end
|
||||
|
||||
return M
|
||||
57
config/yazi/plugins/hexyl.yazi/main.lua
Normal file
57
config/yazi/plugins/hexyl.yazi/main.lua
Normal file
@ -0,0 +1,57 @@
|
||||
local M = {}
|
||||
|
||||
function M:peek(job)
|
||||
local child
|
||||
local l = self.file.cha.len
|
||||
if l == 0 then
|
||||
child = Command("hexyl")
|
||||
:args({
|
||||
tostring(job.file.url),
|
||||
})
|
||||
:stdout(Command.PIPED)
|
||||
:stderr(Command.PIPED)
|
||||
:spawn()
|
||||
else
|
||||
child = Command("hexyl")
|
||||
:args({
|
||||
"--border",
|
||||
"none",
|
||||
"--terminal-width",
|
||||
tostring(job.area.w),
|
||||
tostring(job.file.url),
|
||||
})
|
||||
:stdout(Command.PIPED)
|
||||
:stderr(Command.PIPED)
|
||||
:spawn()
|
||||
end
|
||||
|
||||
local limit = job.area.h
|
||||
local i, lines = 0, ""
|
||||
repeat
|
||||
local next, event = child:read_line()
|
||||
if event == 1 then
|
||||
ya.err(tostring(event))
|
||||
elseif event ~= 0 then
|
||||
break
|
||||
end
|
||||
|
||||
i = i + 1
|
||||
if i > job.skip then
|
||||
lines = lines .. next
|
||||
end
|
||||
until i >= job.skip + limit
|
||||
|
||||
child:start_kill()
|
||||
if job.skip > 0 and i < job.skip + limit then
|
||||
ya.manager_emit("peek", { math.max(0, i - limit), only_if = job.file.url, upper_bound = true })
|
||||
else
|
||||
lines = lines:gsub("\t", string.rep(" ", PREVIEW.tab_size))
|
||||
ya.preview_widgets(job, { ui.Text.parse(lines):area(job.area) })
|
||||
end
|
||||
end
|
||||
|
||||
function M:seek(units)
|
||||
require("code").seek(job, units)
|
||||
end
|
||||
|
||||
return M
|
||||
25
config/yazi/plugins/hide-preview.yazi/main.lua
Normal file
25
config/yazi/plugins/hide-preview.yazi/main.lua
Normal file
@ -0,0 +1,25 @@
|
||||
--- @sync entry
|
||||
|
||||
local function entry(st)
|
||||
if st.old then
|
||||
Tab.layout, st.old = st.old, nil
|
||||
else
|
||||
st.old = Tab.layout
|
||||
Tab.layout = function(self)
|
||||
local all = MANAGER.ratio.parent + MANAGER.ratio.current
|
||||
self._chunks = ui.Layout()
|
||||
:direction(ui.Layout.HORIZONTAL)
|
||||
:constraints({
|
||||
ui.Constraint.Ratio(MANAGER.ratio.parent, all),
|
||||
ui.Constraint.Ratio(MANAGER.ratio.current, all),
|
||||
ui.Constraint.Length(1),
|
||||
})
|
||||
:split(self._area)
|
||||
end
|
||||
end
|
||||
ya.app_emit("resize", {})
|
||||
end
|
||||
|
||||
local function enabled(st) return st.old ~= nil end
|
||||
|
||||
return { entry = entry, enabled = enabled }
|
||||
24
config/yazi/plugins/max-preview.yazi/main.lua
Normal file
24
config/yazi/plugins/max-preview.yazi/main.lua
Normal file
@ -0,0 +1,24 @@
|
||||
--- @sync entry
|
||||
|
||||
local function entry(st)
|
||||
if st.old then
|
||||
Tab.layout, st.old = st.old, nil
|
||||
else
|
||||
st.old = Tab.layout
|
||||
Tab.layout = function(self)
|
||||
self._chunks = ui.Layout()
|
||||
:direction(ui.Layout.HORIZONTAL)
|
||||
:constraints({
|
||||
ui.Constraint.Percentage(0),
|
||||
ui.Constraint.Percentage(0),
|
||||
ui.Constraint.Percentage(100),
|
||||
})
|
||||
:split(self._area)
|
||||
end
|
||||
end
|
||||
ya.app_emit("resize", {})
|
||||
end
|
||||
|
||||
local function enabled(st) return st.old ~= nil end
|
||||
|
||||
return { entry = entry, enabled = enabled }
|
||||
1
config/yazi/plugins/mediainfo.yazi/main.lua
Symbolic link
1
config/yazi/plugins/mediainfo.yazi/main.lua
Symbolic link
@ -0,0 +1 @@
|
||||
/home/kristofers/Nextcloud/repos/solorice/config/yazi/plugins/mediainfo.yazi/init.lua
|
||||
59
config/yazi/plugins/miller.yazi/main.lua
Normal file
59
config/yazi/plugins/miller.yazi/main.lua
Normal file
@ -0,0 +1,59 @@
|
||||
local M = {}
|
||||
|
||||
function M:peek()
|
||||
local child = Command("mlr")
|
||||
:args({
|
||||
"--icsv",
|
||||
"--opprint",
|
||||
"-C",
|
||||
"--key-color",
|
||||
"darkcyan",
|
||||
"--value-color",
|
||||
"grey70",
|
||||
"cat",
|
||||
tostring(self.file.url),
|
||||
})
|
||||
:stdout(Command.PIPED)
|
||||
:stderr(Command.PIPED)
|
||||
:spawn()
|
||||
|
||||
local limit = self.area.h
|
||||
local i, lines = 0, ""
|
||||
repeat
|
||||
local next, event = child:read_line()
|
||||
if event == 1 then
|
||||
ya.err(tostring(event))
|
||||
elseif event ~= 0 then
|
||||
break
|
||||
end
|
||||
|
||||
i = i + 1
|
||||
if i > self.skip then
|
||||
lines = lines .. next
|
||||
end
|
||||
until i >= self.skip + limit
|
||||
|
||||
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 = "" }
|
||||
)
|
||||
else
|
||||
lines = lines:gsub("\t", string.rep(" ", PREVIEW.tab_size))
|
||||
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", {
|
||||
tostring(math.max(0, cx.active.preview.skip + step)),
|
||||
only_if = tostring(self.file.url),
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
58
config/yazi/plugins/nbpreview.yazi/main.lua
Normal file
58
config/yazi/plugins/nbpreview.yazi/main.lua
Normal file
@ -0,0 +1,58 @@
|
||||
local M = {}
|
||||
|
||||
function M:peek(job)
|
||||
local child = Command("nbpreview")
|
||||
:args({
|
||||
-- DO NOT CHANGE --
|
||||
"--no-paging",
|
||||
"--nerd-font",
|
||||
"--decorated",
|
||||
|
||||
-- OPTIONAL CHANGES --
|
||||
"--no-files",
|
||||
"--unicode",
|
||||
"--color",
|
||||
"--images",
|
||||
|
||||
-- SPECIAL CUSTOMIZATIONS --
|
||||
"--color-system=standard",
|
||||
"--theme=ansi_dark",
|
||||
tostring(job.file.url),
|
||||
})
|
||||
:stdout(Command.PIPED)
|
||||
:stderr(Command.PIPED)
|
||||
:spawn()
|
||||
if not child then
|
||||
return require("code"):peek(job)
|
||||
end
|
||||
|
||||
local limit = job.area.h
|
||||
local i, lines = 0, ""
|
||||
repeat
|
||||
local next, event = child:read_line()
|
||||
if event == 1 then
|
||||
return require("code"):peek(job)
|
||||
elseif event ~= 0 then
|
||||
break
|
||||
end
|
||||
|
||||
i = i + 1
|
||||
if i > job.skip then
|
||||
lines = lines .. next
|
||||
end
|
||||
until i >= job.skip + limit
|
||||
|
||||
child:start_kill()
|
||||
if job.skip > 0 and i < job.skip + limit then
|
||||
ya.manager_emit("peek", { math.max(0, i - limit), only_if = job.file.url, upper_bound = true })
|
||||
else
|
||||
lines = lines:gsub("\t", string.rep(" ", PREVIEW.tab_size))
|
||||
ya.preview_widgets(job, { ui.Text.parse(lines):area(job.area) })
|
||||
end
|
||||
end
|
||||
|
||||
function M:seek(job)
|
||||
require("code"):seek(job)
|
||||
end
|
||||
|
||||
return M
|
||||
@ -15,8 +15,11 @@ If you use latest Yazi from main branch
|
||||
# Linux/macOS
|
||||
git clone https://github.com/ndtoan96/ouch.yazi.git ~/.config/yazi/plugins/ouch.yazi
|
||||
|
||||
# Windows
|
||||
# Windows with cmd
|
||||
git clone https://github.com/ndtoan96/ouch.yazi.git %AppData%\yazi\config\plugins\ouch.yazi
|
||||
|
||||
# Windows with powershell
|
||||
git clone https://github.com/ndtoan96/ouch.yazi.git "$($env:APPDATA)\yazi\config\plugins\ouch.yazi"
|
||||
```
|
||||
|
||||
If you use Yazi <= 0.3.3
|
||||
@ -24,8 +27,11 @@ If you use Yazi <= 0.3.3
|
||||
# Linux/macOS
|
||||
git clone --branch v0.2.1 --single-branch https://github.com/ndtoan96/ouch.yazi.git ~/.config/yazi/plugins/ouch.yazi
|
||||
|
||||
# Windows
|
||||
# Windows with cmd
|
||||
git clone --branch v0.2.1 --single-branch https://github.com/ndtoan96/ouch.yazi.git %AppData%\yazi\config\plugins\ouch.yazi
|
||||
|
||||
# Windows with powershell
|
||||
git clone --branch v0.2.1 --single-branch https://github.com/ndtoan96/ouch.yazi.git "$($env:APPDATA)\yazi\config\plugins\ouch.yazi"
|
||||
```
|
||||
|
||||
Make sure you have [ouch](https://github.com/ouch-org/ouch) installed and in your `PATH`.
|
||||
|
||||
145
config/yazi/plugins/ouch.yazi/main.lua
Normal file
145
config/yazi/plugins/ouch.yazi/main.lua
Normal file
@ -0,0 +1,145 @@
|
||||
local M = {}
|
||||
|
||||
function M:peek(job)
|
||||
local child = Command("ouch")
|
||||
:args({ "l", "-t", "-y", tostring(job.file.url) })
|
||||
:stdout(Command.PIPED)
|
||||
:stderr(Command.PIPED)
|
||||
:spawn()
|
||||
local limit = job.area.h
|
||||
local file_name = string.match(tostring(job.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 >= job.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 job.skip > 0 and num_lines < limit then
|
||||
ya.manager_emit(
|
||||
"peek",
|
||||
{ tostring(math.max(0, job.skip - (limit - num_lines))), only_if = tostring(job.file.url), upper_bound = "" }
|
||||
)
|
||||
else
|
||||
ya.preview_widgets(job, { ui.Text(lines):area(job.area) })
|
||||
end
|
||||
end
|
||||
|
||||
function M:seek(job)
|
||||
local h = cx.active.current.hovered
|
||||
if h and h.url == job.file.url then
|
||||
local step = math.floor(job.units * job.area.h / 10)
|
||||
ya.manager_emit("peek", {
|
||||
math.max(0, cx.active.preview.skip + step),
|
||||
only_if = tostring(job.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(job)
|
||||
local default_fmt = job.args[1]
|
||||
|
||||
ya.manager_emit("escape", { visual = true })
|
||||
|
||||
-- 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
|
||||
326
config/yazi/plugins/relative-motions.yazi/main.lua
Normal file
326
config/yazi/plugins/relative-motions.yazi/main.lua
Normal file
@ -0,0 +1,326 @@
|
||||
-- stylua: ignore
|
||||
local MOTIONS_AND_OP_KEYS = {
|
||||
{ on = "0" }, { on = "1" }, { on = "2" }, { on = "3" }, { on = "4" },
|
||||
{ on = "5" }, { on = "6" }, { on = "7" }, { on = "8" }, { on = "9" },
|
||||
-- commands
|
||||
{ on = "d" }, { on = "v" }, { on = "y" }, { on = "x" },
|
||||
-- tab commands
|
||||
{ on = "t" }, { on = "L" }, { on = "H" }, { on = "w" },
|
||||
{ on = "W" }, { on = "<" }, { on = ">" }, { on = "~" },
|
||||
-- movement
|
||||
{ on = "g" }, { on = "j" }, { on = "k" }, { on = "<Down>" }, { on = "<Up>" }
|
||||
}
|
||||
|
||||
-- stylua: ignore
|
||||
local MOTION_KEYS = {
|
||||
{ on = "0" }, { on = "1" }, { on = "2" }, { on = "3" }, { on = "4" },
|
||||
{ on = "5" }, { on = "6" }, { on = "7" }, { on = "8" }, { on = "9" },
|
||||
-- movement
|
||||
{ on = "g" }, { on = "j" }, { on = "k" }
|
||||
}
|
||||
|
||||
-- stylua: ignore
|
||||
local DIRECTION_KEYS = {
|
||||
{ on = "j" }, { on = "k" }, { on = "<Down>" }, { on = "<Up>" },
|
||||
-- tab movement
|
||||
{ on = "t" }
|
||||
}
|
||||
|
||||
local SHOW_NUMBERS_ABSOLUTE = 0
|
||||
local SHOW_NUMBERS_RELATIVE = 1
|
||||
local SHOW_NUMBERS_RELATIVE_ABSOLUTE = 2
|
||||
|
||||
-----------------------------------------------
|
||||
----------------- R E N D E R -----------------
|
||||
-----------------------------------------------
|
||||
|
||||
local render_motion_setup = ya.sync(function(_)
|
||||
ya.render()
|
||||
|
||||
Status.motion = function() return ui.Span("") end
|
||||
|
||||
Status.children_redraw = 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(function() return ui.Span("") end, 1000, Status.RIGHT)
|
||||
end)
|
||||
|
||||
local render_motion = ya.sync(function(_, motion_num, motion_cmd)
|
||||
ya.render()
|
||||
|
||||
Status.motion = function(self)
|
||||
if not motion_num then
|
||||
return ui.Span("")
|
||||
end
|
||||
|
||||
local style = self:style()
|
||||
|
||||
local motion_span
|
||||
if not motion_cmd then
|
||||
motion_span = ui.Span(string.format(" %3d ", motion_num))
|
||||
else
|
||||
motion_span = ui.Span(string.format(" %3d%s ", motion_num, motion_cmd))
|
||||
end
|
||||
|
||||
return ui.Line {
|
||||
ui.Span(THEME.status.separator_open):fg(style.main.bg),
|
||||
motion_span:style(style.main),
|
||||
ui.Span(THEME.status.separator_close):fg(style.main.bg),
|
||||
ui.Span(" "),
|
||||
}
|
||||
end
|
||||
end)
|
||||
|
||||
local render_numbers = ya.sync(function(_, mode)
|
||||
ya.render()
|
||||
|
||||
Entity.number = function(_, index, file, hovered)
|
||||
local idx
|
||||
if mode == SHOW_NUMBERS_RELATIVE then
|
||||
idx = math.abs(hovered - index)
|
||||
elseif mode == SHOW_NUMBERS_ABSOLUTE then
|
||||
idx = file.idx
|
||||
else -- SHOW_NUMBERS_RELATIVE_ABSOLUTE
|
||||
if hovered == index then
|
||||
idx = file.idx
|
||||
else
|
||||
idx = math.abs(hovered - index)
|
||||
end
|
||||
end
|
||||
|
||||
-- emulate vim's hovered offset
|
||||
if idx >= 100 then
|
||||
return ui.Span(string.format("%4d ", idx))
|
||||
elseif hovered == index then
|
||||
return ui.Span(string.format("%3d ", idx))
|
||||
else
|
||||
return ui.Span(string.format(" %3d ", idx))
|
||||
end
|
||||
end
|
||||
|
||||
Current.redraw = function(self)
|
||||
local files = self._folder.window
|
||||
if #files == 0 then
|
||||
return self:empty()
|
||||
end
|
||||
|
||||
local hovered_index
|
||||
for i, f in ipairs(files) do
|
||||
if f:is_hovered() then
|
||||
hovered_index = i
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
local entities, linemodes = {}, {}
|
||||
for i, f in ipairs(files) do
|
||||
linemodes[#linemodes + 1] = Linemode:new(f):redraw()
|
||||
|
||||
local entity = Entity:new(f)
|
||||
entities[#entities + 1] = ui.Line({ Entity:number(i, f, hovered_index), entity:redraw() }):style(entity:style())
|
||||
end
|
||||
|
||||
return {
|
||||
ui.List(entities):area(self._area),
|
||||
ui.Text(linemodes):area(self._area):align(ui.Text.RIGHT),
|
||||
}
|
||||
end
|
||||
end)
|
||||
|
||||
local function render_clear() render_motion() end
|
||||
|
||||
-----------------------------------------------
|
||||
--------- C O M M A N D P A R S E R ---------
|
||||
-----------------------------------------------
|
||||
|
||||
local get_keys = ya.sync(function(state) return state._only_motions and MOTION_KEYS or MOTIONS_AND_OP_KEYS end)
|
||||
|
||||
local function normal_direction(dir)
|
||||
if dir == "<Down>" then
|
||||
return "j"
|
||||
elseif dir == "<Up>" then
|
||||
return "k"
|
||||
end
|
||||
return dir
|
||||
end
|
||||
|
||||
local function get_cmd(first_char, keys)
|
||||
local last_key
|
||||
local lines = first_char or ""
|
||||
|
||||
while true do
|
||||
render_motion(tonumber(lines))
|
||||
local key = ya.which { cands = keys, silent = true }
|
||||
if not key then
|
||||
return nil, nil, nil
|
||||
end
|
||||
|
||||
last_key = keys[key].on
|
||||
if not tonumber(last_key) then
|
||||
last_key = normal_direction(last_key)
|
||||
break
|
||||
end
|
||||
|
||||
lines = lines .. last_key
|
||||
end
|
||||
|
||||
render_motion(tonumber(lines), last_key)
|
||||
|
||||
-- command direction
|
||||
local direction
|
||||
if last_key == "g" or last_key == "v" or last_key == "d" or last_key == "y" or last_key == "x" then
|
||||
DIRECTION_KEYS[#DIRECTION_KEYS + 1] = {
|
||||
on = last_key,
|
||||
}
|
||||
local direction_key = ya.which { cands = DIRECTION_KEYS, silent = true }
|
||||
if not direction_key then
|
||||
return nil, nil, nil
|
||||
end
|
||||
|
||||
direction = DIRECTION_KEYS[direction_key].on
|
||||
direction = normal_direction(direction)
|
||||
end
|
||||
|
||||
return tonumber(lines), last_key, direction
|
||||
end
|
||||
|
||||
local function is_tab_command(command)
|
||||
local tab_commands = { "t", "L", "H", "w", "W", "<", ">", "~" }
|
||||
for _, cmd in ipairs(tab_commands) do
|
||||
if command == cmd then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
local get_active_tab = ya.sync(function(_) return cx.tabs.idx end)
|
||||
|
||||
-----------------------------------------------
|
||||
---------- E N T R Y / S E T U P ----------
|
||||
-----------------------------------------------
|
||||
|
||||
return {
|
||||
entry = function(_, job)
|
||||
local initial_value
|
||||
|
||||
local args = job.args
|
||||
-- this is checking if the argument is a valid number
|
||||
if #args > 0 then
|
||||
initial_value = tostring(tonumber(args[1]))
|
||||
if initial_value == "nil" then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
local lines, cmd, direction = get_cmd(initial_value, get_keys())
|
||||
if not lines or not cmd then
|
||||
-- command was cancelled
|
||||
render_clear()
|
||||
return
|
||||
end
|
||||
|
||||
if cmd == "g" then
|
||||
if direction == "g" then
|
||||
ya.manager_emit("arrow", { -99999999 })
|
||||
ya.manager_emit("arrow", { lines - 1 })
|
||||
render_clear()
|
||||
return
|
||||
elseif direction == "j" then
|
||||
cmd = "j"
|
||||
elseif direction == "k" then
|
||||
cmd = "k"
|
||||
elseif direction == "t" then
|
||||
ya.manager_emit("tab_switch", { lines - 1 })
|
||||
render_clear()
|
||||
return
|
||||
else
|
||||
-- no valid direction
|
||||
render_clear()
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
if cmd == "j" then
|
||||
ya.manager_emit("arrow", { lines })
|
||||
elseif cmd == "k" then
|
||||
ya.manager_emit("arrow", { -lines })
|
||||
elseif is_tab_command(cmd) then
|
||||
if cmd == "t" then
|
||||
for _ = 1, lines do
|
||||
ya.manager_emit("tab_create", {})
|
||||
end
|
||||
elseif cmd == "H" then
|
||||
ya.manager_emit("tab_switch", { -lines, relative = true })
|
||||
elseif cmd == "L" then
|
||||
ya.manager_emit("tab_switch", { lines, relative = true })
|
||||
elseif cmd == "w" then
|
||||
ya.manager_emit("tab_close", { lines - 1 })
|
||||
elseif cmd == "W" then
|
||||
local curr_tab = get_active_tab()
|
||||
local del_tab = curr_tab + lines - 1
|
||||
for _ = curr_tab, del_tab do
|
||||
ya.manager_emit("tab_close", { curr_tab - 1 })
|
||||
end
|
||||
ya.manager_emit("tab_switch", { curr_tab - 1 })
|
||||
elseif cmd == "<" then
|
||||
ya.manager_emit("tab_swap", { -lines })
|
||||
elseif cmd == ">" then
|
||||
ya.manager_emit("tab_swap", { lines })
|
||||
elseif cmd == "~" then
|
||||
local jump = lines - get_active_tab()
|
||||
ya.manager_emit("tab_swap", { jump })
|
||||
end
|
||||
else
|
||||
ya.manager_emit("visual_mode", {})
|
||||
-- invert direction when user specifies it
|
||||
if direction == "k" then
|
||||
ya.manager_emit("arrow", { -lines })
|
||||
elseif direction == "j" then
|
||||
ya.manager_emit("arrow", { lines })
|
||||
else
|
||||
ya.manager_emit("arrow", { lines - 1 })
|
||||
end
|
||||
ya.manager_emit("escape", {})
|
||||
|
||||
if cmd == "d" then
|
||||
ya.manager_emit("remove", {})
|
||||
elseif cmd == "y" then
|
||||
ya.manager_emit("yank", {})
|
||||
elseif cmd == "x" then
|
||||
ya.manager_emit("yank", { cut = true })
|
||||
end
|
||||
end
|
||||
|
||||
render_clear()
|
||||
end,
|
||||
setup = function(state, args)
|
||||
if not args then
|
||||
return
|
||||
end
|
||||
|
||||
-- initialize state variables
|
||||
state._only_motions = args["only_motions"] or false
|
||||
|
||||
if args["show_motion"] then
|
||||
render_motion_setup()
|
||||
end
|
||||
|
||||
if args["show_numbers"] == "absolute" then
|
||||
render_numbers(SHOW_NUMBERS_ABSOLUTE)
|
||||
elseif args["show_numbers"] == "relative" then
|
||||
render_numbers(SHOW_NUMBERS_RELATIVE)
|
||||
elseif args["show_numbers"] == "relative_absolute" then
|
||||
render_numbers(SHOW_NUMBERS_RELATIVE_ABSOLUTE)
|
||||
end
|
||||
end,
|
||||
}
|
||||
1
config/yazi/plugins/starship.yazi/main.lua
Symbolic link
1
config/yazi/plugins/starship.yazi/main.lua
Symbolic link
@ -0,0 +1 @@
|
||||
/home/kristofers/Nextcloud/repos/solorice/config/yazi/plugins/starship.yazi/init.lua
|
||||
46
config/yazi/plugins/torrent-preview.yazi/main.lua
Normal file
46
config/yazi/plugins/torrent-preview.yazi/main.lua
Normal file
@ -0,0 +1,46 @@
|
||||
local M = {}
|
||||
|
||||
function M:peek(job)
|
||||
local child = Command("transmission-show")
|
||||
:args({
|
||||
tostring(job.file.url),
|
||||
})
|
||||
:stdout(Command.PIPED)
|
||||
:stderr(Command.PIPED)
|
||||
:spawn()
|
||||
|
||||
if not child then
|
||||
return require("code"):peek(job)
|
||||
end
|
||||
|
||||
local limit = job.area.h
|
||||
local i, lines = 0, ""
|
||||
repeat
|
||||
local next, event = child:read_line()
|
||||
if event == 1 then
|
||||
return require("code"):peek(job)
|
||||
elseif event ~= 0 then
|
||||
break
|
||||
end
|
||||
|
||||
i = i + 1
|
||||
if i > job.skip then
|
||||
lines = lines .. next
|
||||
end
|
||||
until i >= job.skip + limit
|
||||
|
||||
child:start_kill()
|
||||
if job.skip > 0 and i < job.skip + limit then
|
||||
ya.manager_emit("peek", { math.max(0, i - limit), only_if = job.file.url, upper_bound = true })
|
||||
else
|
||||
lines = lines:gsub("\t", string.rep(" ", PREVIEW.tab_size))
|
||||
ya.preview_widgets(job, { ui.Text.parse(lines):area(job.area) })
|
||||
end
|
||||
end
|
||||
|
||||
function M:seek(job)
|
||||
require("code"):seek(job)
|
||||
end
|
||||
|
||||
return M
|
||||
|
||||
72
config/yazi/plugins/what-size.yazi/main.lua
Normal file
72
config/yazi/plugins/what-size.yazi/main.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, job)
|
||||
-- defaults not to use clipboard, use it only if required by the user
|
||||
local clipboard = job.args.clipboard or job.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,
|
||||
}
|
||||
1312
config/yazi/plugins/yatline.yazi/main.lua
Normal file
1312
config/yazi/plugins/yatline.yazi/main.lua
Normal file
File diff suppressed because it is too large
Load Diff
@ -92,12 +92,12 @@ previewers = [
|
||||
# JSON
|
||||
{mime = "application/json", run = "code"},
|
||||
# Image
|
||||
# {mime = "image/vnd.djvu", run = "noop"},
|
||||
# {mime = "image/*", run = "image"},
|
||||
{mime = "image/vnd.djvu", run = "noop"},
|
||||
{mime = "image/*", run = "image"},
|
||||
# Video
|
||||
# {mime = "video/*", run = "video"},
|
||||
{mime = "video/*", run = "video"},
|
||||
# PDF
|
||||
# {mime = "application/pdf", run = "pdf"},
|
||||
{mime = "application/pdf", run = "pdf"},
|
||||
# Fallback
|
||||
{name = "*", run = "file"},
|
||||
]
|
||||
|
||||
0
dotter.arm
Normal file → Executable file
0
dotter.arm
Normal file → Executable file
0
dotter.exe
Normal file → Executable file
0
dotter.exe
Normal file → Executable file
Loading…
Reference in New Issue
Block a user