Created
March 23, 2025 04:10
-
-
Save LaptopDev/058d600279602eb2a7f49897d5a4f1bd to your computer and use it in GitHub Desktop.
log opened files in neovim
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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