From 28e8bdf7f8286bd431b7f3b709e79f3827b31469 Mon Sep 17 00:00:00 2001 From: TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> Date: Wed, 24 Dec 2025 13:54:03 +0900 Subject: updates --- debian/.config/yazi/plugins/diff.yazi/README.md | 28 +++++++++++++++++ debian/.config/yazi/plugins/diff.yazi/main.lua | 41 +++++++++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 debian/.config/yazi/plugins/diff.yazi/README.md create mode 100644 debian/.config/yazi/plugins/diff.yazi/main.lua (limited to 'debian/.config/yazi/plugins/diff.yazi') diff --git a/debian/.config/yazi/plugins/diff.yazi/README.md b/debian/.config/yazi/plugins/diff.yazi/README.md new file mode 100644 index 0000000..1976541 --- /dev/null +++ b/debian/.config/yazi/plugins/diff.yazi/README.md @@ -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 pkg add yazi-rs/plugins:diff +``` + +## Usage + +Add this to your `~/.config/yazi/keymap.toml`: + +```toml +[[mgr.prepend_keymap]] +on = "" +run = "plugin diff" +desc = "Diff the selected with the hovered file" +``` + +Make sure the C + d key is not used elsewhere. + +## License + +This plugin is MIT-licensed. For more information check the [LICENSE](LICENSE) file. diff --git a/debian/.config/yazi/plugins/diff.yazi/main.lua b/debian/.config/yazi/plugins/diff.yazi/main.lua new file mode 100644 index 0000000..21dde6d --- /dev/null +++ b/debian/.config/yazi/plugins/diff.yazi/main.lua @@ -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, +} -- cgit v1.2.3