Open kyletruong opened 1 month ago
Can you share what exactly you are giving into the input? I have been meaning to look into this, just didnt do it yet
@AnirudhG07 Yes, for example when I run nvim $0
it opens a new file called zsh
instead of opening the currently hovered file.
I see. fine ill work on fixing this issue. If you would like to contribute, you are very welcome to(do inform me, if you are doing it)! It would take a week-ish, since i am bit busy these days. i hope its fine with you
How is the progress? I am also encountering this issue now, unable to parse $@
after using this plugin.
:
echo $@
it will echo the path of two files.
plugin custom-shell --args=auto
echo $@
it echo nothing
I think the problem lies in sh -c 'zsh -ic "echo $@; exit"'
, where $@
is not being interpreted correctly.
It may relate to https://github.com/sxyazi/yazi/issues/1524
I don't know how to handle it.
Yes. zsh or any shell does not interpret $0
as yazi does. I will work on it. I'll have to look into how to get it to work. Give me some more time
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()
local paths = table.concat(urls, " ")
local value, event = ya.input {
title = "Zsh shell:",
position = { "top-center", y = 3, w = 40 },
}
if event == 1 then
if value:match("%s$@$") then
value = value:gsub("%s$@$", " " .. paths)
end
ya.notify({
title = "exec",
content = "zsh -ic " .. ya.quote(value .. "; exit", true),
-- content = table.concat(urls, " "),
timeout = 8,
})
ya.manager_emit("shell", {
"zsh -ic " .. ya.quote(value .. "; exit", true),
block = true,
confirm = true,
})
end
end,
}
Take a look at this. It might be a bit clumsy, but it works. Forcibly replace $@
with selected_or_hovered. Perhaps this is unacceptable for this repo.
I was also thinking in similar direction, but this has to carefully applied so that it works properly with pre-added configs. Thanks for the snippet though, might come in handy.
I think you can just string.format('zsh -ic %s "$0" "$@"', ya.quote(value .. '; exit', true))
After adding this plugin, the
$0
shell variable no longer resolves to the hovered file. It resolves tozsh
in my case, which is my custom shell.