pull out last_modified_days

Sun, 05 May 2024 02:13:36 -0500

author
Meredith Howard <mhoward@roomag.org>
date
Sun, 05 May 2024 02:13:36 -0500
changeset 1156
0a7162df160d
parent 1155
fcec334dfe7a
child 1157
a237720efee9

pull out last_modified_days

.config/nvim/lua/config/commands.lua file | annotate | diff | comparison | revisions
.config/nvim/lua/config/util.lua file | annotate | diff | comparison | revisions
--- a/.config/nvim/lua/config/commands.lua
+++ b/.config/nvim/lua/config/commands.lua
@@ -1,7 +1,8 @@
 local command = vim.api.nvim_create_user_command
 local cmd, fn = vim.cmd, vim.fn
+local util = require("config.util")
 
-require("config.util").calias({
+util.calias({
   -- replace default:
   grep = "Grep",
 
@@ -55,7 +56,7 @@ command("PruneSession", function()
     if name then
       local type = vim.fn.getftype(name)
       if type == "" or type == "dir"
-        or (os.time() - vim.fn.getftime(name)) > 2592000
+        or util.last_modified_days(name) > 30
       then
         vim.print("pruned: " .. name)
         vim.cmd.bwipeout(bufnr)
--- a/.config/nvim/lua/config/util.lua
+++ b/.config/nvim/lua/config/util.lua
@@ -45,4 +45,8 @@ function M.safe_filter_file(cmd)
   fn.delete(errorfile)
 end
 
+function M.last_modified_days(fname)
+  return (os.time() - vim.fn.getftime(fname)) / 86400
+end
+
 return M

mercurial