mirror of
https://github.com/kristoferssolo/solorice.git
synced 2026-02-04 06:32:03 +00:00
fix(yazi): update plugins
This commit is contained in:
21
config/yazi/plugins/diff.yazi/LICENSE
Normal file
21
config/yazi/plugins/diff.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.
|
||||
28
config/yazi/plugins/diff.yazi/README.md
Normal file
28
config/yazi/plugins/diff.yazi/README.md
Normal file
@@ -0,0 +1,28 @@
|
||||
# diff.yazi
|
||||
|
||||
Diff the selected file with the hovered file, create a living patch, and copy it to the clipboard.
|
||||
|
||||
https://github.com/yazi-rs/plugins/assets/17523360/eff5e949-386a-44ea-82f9-4cb4a2c37aad
|
||||
|
||||
## Installation
|
||||
|
||||
```sh
|
||||
ya pack -a yazi-rs/plugins:diff
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
Add this to your `~/.config/yazi/keymap.toml`:
|
||||
|
||||
```toml
|
||||
[[manager.prepend_keymap]]
|
||||
on = "<C-d>"
|
||||
run = "plugin diff"
|
||||
desc = "Diff the selected with the hovered file"
|
||||
```
|
||||
|
||||
Make sure the <kbd>C</kbd> + <kbd>d</kbd> key is not used elsewhere.
|
||||
|
||||
## License
|
||||
|
||||
This plugin is MIT-licensed. For more information check the [LICENSE](LICENSE) file.
|
||||
41
config/yazi/plugins/diff.yazi/main.lua
Normal file
41
config/yazi/plugins/diff.yazi/main.lua
Normal file
@@ -0,0 +1,41 @@
|
||||
--- @since 25.2.7
|
||||
|
||||
local function info(content)
|
||||
return ya.notify {
|
||||
title = "Diff",
|
||||
content = content,
|
||||
timeout = 5,
|
||||
}
|
||||
end
|
||||
|
||||
local selected_url = ya.sync(function()
|
||||
for _, u in pairs(cx.active.selected) do
|
||||
return u
|
||||
end
|
||||
end)
|
||||
|
||||
local hovered_url = ya.sync(function()
|
||||
local h = cx.active.current.hovered
|
||||
return h and h.url
|
||||
end)
|
||||
|
||||
return {
|
||||
entry = function()
|
||||
local a, b = selected_url(), hovered_url()
|
||||
if not a then
|
||||
return info("No file selected")
|
||||
elseif not b then
|
||||
return info("No file hovered")
|
||||
end
|
||||
|
||||
local output, err = Command("diff"):arg("-Naur"):arg(tostring(a)):arg(tostring(b)):output()
|
||||
if not output then
|
||||
return info("Failed to run diff, error: " .. err)
|
||||
elseif output.stdout == "" then
|
||||
return info("No differences found")
|
||||
end
|
||||
|
||||
ya.clipboard(output.stdout)
|
||||
info("Diff copied to clipboard")
|
||||
end,
|
||||
}
|
||||
Reference in New Issue
Block a user