40 lines
895 B
Lua
40 lines
895 B
Lua
local temp_dir = os.getenv("TEMP") or os.getenv("TMP") or "/tmp"
|
|
local file_name = temp_dir .. "/bookmark.yazi"
|
|
|
|
local save_bookmark = ya.sync(function(state, idx)
|
|
local folder = tostring(cx.active.current.cwd)
|
|
local file = io.open(file_name, "w")
|
|
|
|
if file then
|
|
file:write(folder)
|
|
file:close()
|
|
ya.notify { title = "Saved Bookmark", content = folder, timeout = 3, level = "info" }
|
|
end
|
|
end)
|
|
|
|
local jump_bookmark = ya.sync(function(state, idx)
|
|
local file = io.open(file_name, "r")
|
|
|
|
if file then
|
|
local line = file:read("*line")
|
|
file:close()
|
|
ya.manager_emit("cd", { line })
|
|
ya.manager_emit("arrow", { -99999999 })
|
|
end
|
|
end)
|
|
|
|
return {
|
|
entry = function(_, job)
|
|
local action = job.args[1]
|
|
if not action then
|
|
return
|
|
end
|
|
|
|
if action == "save" then
|
|
save_bookmark()
|
|
elseif action == "jump" then
|
|
jump_bookmark()
|
|
end
|
|
end
|
|
}
|