Also call save_dir when opening parent

This commit is contained in:
Thomas Avé 2024-04-10 13:46:15 +02:00
parent 2f01eaf9f9
commit d2bf13d6f6
1 changed files with 7 additions and 6 deletions

View File

@ -1,11 +1,12 @@
local function store_select() local function save_dir()
require("oil").select({}, function() local dir = require("oil").get_current_dir()
if dir ~= nil then
local f = io.open("/tmp/oil_dir", "w") local f = io.open("/tmp/oil_dir", "w")
if f then if f then
f:write(require("oil").get_current_dir()) f:write(dir)
f:close() f:close()
end end
end) end
end end
return { return {
@ -14,13 +15,13 @@ return {
opts = { opts = {
keymaps = { keymaps = {
["g?"] = "actions.show_help", ["g?"] = "actions.show_help",
["<CR>"] = store_select, ["<CR>"] = function() require("oil").select({}, save_dir) end,
["<leader>v"] = "actions.select_vsplit", ["<leader>v"] = "actions.select_vsplit",
["<leader>s"] = "actions.select_split", ["<leader>s"] = "actions.select_split",
["<leader>p"] = "actions.preview", ["<leader>p"] = "actions.preview",
["<backspace>"] = "actions.close", ["<backspace>"] = "actions.close",
["<leader>r"] = "actions.refresh", ["<leader>r"] = "actions.refresh",
["-"] = "actions.parent", ["-"] = function() require("oil").open(); save_dir() end,
["_"] = "actions.open_cwd", ["_"] = "actions.open_cwd",
["`"] = "actions.cd", ["`"] = "actions.cd",
["~"] = "actions.tcd", ["~"] = "actions.tcd",