40 lines
842 B
Lua
40 lines
842 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 = Folder:by_kind(Folder.CURRENT)
|
|
local file = io.open(file_name, "w")
|
|
|
|
if file then
|
|
file:write(tostring(folder.cwd))
|
|
file:close()
|
|
end
|
|
end)
|
|
|
|
local jump_bookmark = ya.sync(function(state, idx)
|
|
local io = require("io")
|
|
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(_, args)
|
|
local action = args[1]
|
|
if not action then
|
|
return
|
|
end
|
|
|
|
if action == "save" then
|
|
save_bookmark()
|
|
elseif action == "jump" then
|
|
jump_bookmark()
|
|
end
|
|
end
|
|
}
|