From 263cb2c1c065d19d2da5d0957c097e9179b90994 Mon Sep 17 00:00:00 2001 From: Daniel Fichtinger Date: Wed, 12 Feb 2025 12:05:05 -0500 Subject: [PATCH] AutoYADM commit: 2025-02-12 12:05:05 --- .config/yazi/keymap-default.toml | 2 +- .config/yazi/keymap.toml | 1 + .config/yazi/package.toml | 6 +++-- .../yazi/plugins/open-with-cmd.yazi/LICENSE | 19 ++++++++++++++ .../yazi/plugins/open-with-cmd.yazi/README.md | 25 +++++++++++++++++++ .../yazi/plugins/open-with-cmd.yazi/main.lua | 20 +++++++++++++++ 6 files changed, 70 insertions(+), 3 deletions(-) create mode 100644 .config/yazi/plugins/open-with-cmd.yazi/LICENSE create mode 100644 .config/yazi/plugins/open-with-cmd.yazi/README.md create mode 100644 .config/yazi/plugins/open-with-cmd.yazi/main.lua diff --git a/.config/yazi/keymap-default.toml b/.config/yazi/keymap-default.toml index 31f0cc97..146be07e 100644 --- a/.config/yazi/keymap-default.toml +++ b/.config/yazi/keymap-default.toml @@ -264,7 +264,7 @@ keymap = [ { on = "_", run = "move first-char", desc = "Move to the first non-whitespace character" }, { on = "^", run = "move first-char", desc = "Move to the first non-whitespace character" }, { on = "", run = "move bol", desc = "Move to the BOL" }, - { on = "", run = "move eol", desc = "Move to the EOL" }, + { on = "", run = "move eol", desc = "Move to the EOL" }, { on = "", run = "move bol", desc = "Move to the BOL" }, { on = "", run = "move eol", desc = "Move to the EOL" }, diff --git a/.config/yazi/keymap.toml b/.config/yazi/keymap.toml index dd46381d..c3a4114b 100644 --- a/.config/yazi/keymap.toml +++ b/.config/yazi/keymap.toml @@ -42,6 +42,7 @@ prepend_keymap = [ "g", "r", ], run = 'shell -- ya emit cd "$(git rev-parse --show-toplevel)"', desc = "Goto git root"}, + # {on = "", run = 'o'} ] [input] diff --git a/.config/yazi/package.toml b/.config/yazi/package.toml index 95de2026..3bff43db 100644 --- a/.config/yazi/package.toml +++ b/.config/yazi/package.toml @@ -1,5 +1,7 @@ -[plugin] -deps = [] +[[plugin.deps]] +use = "Ape/open-with-cmd" +rev = "433cf30" +hash = "86e0312b01bc5762813c6c1d0517f073" [[flavor.deps]] use = "ashen-org/ashen:ashen" diff --git a/.config/yazi/plugins/open-with-cmd.yazi/LICENSE b/.config/yazi/plugins/open-with-cmd.yazi/LICENSE new file mode 100644 index 00000000..0399f1c2 --- /dev/null +++ b/.config/yazi/plugins/open-with-cmd.yazi/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2024 Lauri Niskanen + +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. diff --git a/.config/yazi/plugins/open-with-cmd.yazi/README.md b/.config/yazi/plugins/open-with-cmd.yazi/README.md new file mode 100644 index 00000000..98058234 --- /dev/null +++ b/.config/yazi/plugins/open-with-cmd.yazi/README.md @@ -0,0 +1,25 @@ +# open-with-cmd.yazi + +This is a Yazi plugin for opening files with a prompted command. + +## Installation + +Install the plugin: + +``` +ya pack -a Ape/open-with-cmd +``` + +Create `~/.config/yazi/keymap.toml` and add: + +``` +[[manager.prepend_keymap]] +on = "o" +run = "plugin open-with-cmd --args=block" +desc = "Open with command in the terminal" + +[[manager.prepend_keymap]] +on = "O" +run = "plugin open-with-cmd" +desc = "Open with command" +``` diff --git a/.config/yazi/plugins/open-with-cmd.yazi/main.lua b/.config/yazi/plugins/open-with-cmd.yazi/main.lua new file mode 100644 index 00000000..fee405fa --- /dev/null +++ b/.config/yazi/plugins/open-with-cmd.yazi/main.lua @@ -0,0 +1,20 @@ +return { + entry = function(_, job) + local block = job.args[1] and job.args[1] == "block" + + local value, event = ya.input({ + title = block and "Open with (block):" or "Open with:", + position = { "hovered", y = 1, w = 50 }, + }) + + if event == 1 then + local s = ya.target_family() == "windows" and " %*" or ' "$@"' + ya.manager_emit("shell", { + value .. s, + block = block, + orphan = true, + confirm = true, + }) + end + end, +}