neorg icon indicating copy to clipboard operation
neorg copied to clipboard

`:Neorg journal previous`

Open Anrock opened this issue 5 months ago • 3 comments

Issues

  • [x] I have checked existing issues and there are no existing ones with the same request.

Feature description

I use neorg journal exclusively to document wtf I'm doing at work. There is a convenient shortcut :Neorg journal yesterday that opens journal entry from previous day. However it doesn't work on monday after weekend since last entry was on friday.

I'd like to to have a :Neorg journal previous shortcut that opens most recent entry from the past.

Help

No

Implementation help

No response

Anrock avatar Aug 06 '25 13:08 Anrock

I have created a workaround for this in the form of a custom keybind. Unfortunately it's only on my work machine. I will make a reminder to email it to myself on monday!

(If my employer is reading this, don't worry, it's like maybe 10 lines of lua, and it's not sensitive IP, and I'll ask for approval anyway)

benlubas avatar Oct 03 '25 23:10 benlubas

local function yesterweekday()
  local day = os.date("*t", os.time()) --[[@as osdate]]
  if day.wday == 2 then
    day.day = day.day - 3
  elseif day.wday == 1 then
    day.day = day.day - 2
  else
    day.day = day.day - 1
  end
  return os.date("%Y-%m-%d", os.time(day))
end
{ "<leader>jy", function() return (":Neorg journal custom %s<CR>"):format(yesterweekday()) end, desc = "Journal Yesterday", silent = true, expr = true }

benlubas avatar Oct 17 '25 00:10 benlubas

That's neat, but not quite what OP asked for since yesterday's (or yesterweekday's) journal entry might not exist. In vimwiki you could go back and forth between the previous and next journal entries even if you skipped a few days, that's more like what OP is looking for.

mlysle avatar Nov 24 '25 00:11 mlysle