forked from saumyajyoti/omp.yazi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.lua
37 lines (34 loc) · 892 Bytes
/
init.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
local save = ya.sync(function(st, cwd, output)
if cx.active.current.cwd == Url(cwd) then
st.output = output
ya.render()
end
end)
return {
setup = function(st)
Header:children_remove(1, Header.LEFT)
Header:children_add(function() return ui.Line.parse(st.output or "") end, 1000, Header.LEFT)
ps.sub("cd", function()
local cwd = cx.active.current.cwd
if st.cwd ~= cwd then
st.cwd = cwd
ya.manager_emit("plugin", { st._id, args = ya.quote(tostring(cwd), true) })
end
end)
end,
entry = function(_, job)
local output = Command("oh-my-posh")
:args({
"print",
"primary",
"--no-status",
"-c",
"https://raw.githubusercontent.com/saumyajyoti/omp.yazi/main/yazi-prompt.omp.json",
})
:cwd(job.args[1])
:output()
if output then
save(job.args[1], output.stdout:gsub("^%s+", ""))
end
end,
}