Skip to content

Instantly share code, notes, and snippets.

@LaptopDev
Created March 23, 2025 04:10
Show Gist options
  • Save LaptopDev/058d600279602eb2a7f49897d5a4f1bd to your computer and use it in GitHub Desktop.
Save LaptopDev/058d600279602eb2a7f49897d5a4f1bd to your computer and use it in GitHub Desktop.
log opened files in neovim
-- Log file opening to last_opened.txt
vim.api.nvim_create_autocmd("BufReadPost", {
callback = function()
local date = os.date("%b %d, %Y") -- Format the current date
local file_path = vim.fn.shellescape(vim.fn.expand("<afile>:p"))
os.execute(string.format("sed -i '1i%s' /home/user/.config/nvim/last_opened.txt", date .. " " .. file_path))
end,
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment