Hacker News new | ask | show | jobs
by hoherd 483 days ago
I do something similar for daily notes for work. I have a shell alias `tdw` for `TODO work` which opens a YYYY-MM.md file in vim. Inside of that markdown file I use a vim macro that generates a date similar to what is shown in calendar.txt, where I take notes about what I am working on and what I have worked on. Here's ane example of what it looks like:

    ## 2025-02-27 W09 Thursday
    
    - Team standup
    - Looking up flights to Venus
    - Meeting with Acme
      - Discuss hydrocoptic marzlevanes
      - TODO: read up on them <http://example.com/docs/hydrocoptic-marzlevanes>
    - (personal) Feed the dragon
    - #5934 Fix glitch in dingle arm reciprocator
I kind of like the calendar.txt idea of prefixing every line with the date, because it makes grepping easier, but at the same time, it doesn't allow for sub-lists and more detailed notes about what was worked on. It hasn't been a big enough problem to deal with though, because of things like `grep -i -B10 encabulator`

The vim macro I use is:

    " Macro To Do Today
    nmap mtdt <esc>O<CR><esc>k"=strftime('## %F W%V %A')<CR>Pa<CR><CR>-
5 comments

I've got something very similar as a function in my ~/.zshrc, except instead of days separated by lines I start a new file for each topic.

Most of my notes are write-only for a day or so but I keep the old ones around just in case I need to grep through everything (and I've saved myself doing this a few times).

    function notes {
      THIS_MONTH="$(date '+%Y-%m')"

      mkdir -p "$NOTES_FOLDER/$THIS_MONTH" # create folder if it doesn't exist.
      cd "$NOTES_FOLDER/$THIS_MONTH"

      if [ -z "$1" ]; then
        return 0
      fi

      vim $1
      cd -
    }
Running `notes` will take you to today's directory to poke around, and `notes file.md` will open file.md in the appropriate dir.
I do something very similar for my public notes as well! I have `tn` to search for a note and open it in a browser, and `tne foo` to open my `foo.md` note in my editor, which in this case is not vim. I then commit them to git, where a post-commit hook uses mkdocs to build them, and gh-deploy to publish them EG https://danielhoherd.com/tech-notes/exiftool/ is the output of my exiftool.md note.
I use vimwiki[1] just for this "diary" functionality, with different days in different files. Can browse the directory in netrw to find a day's notes, and I have scripts that let me archive old stuff. I tend to put an "x" in front of completed lines (and move uncompleted lines forward to new days) so it is easy to detect and archive unactionable or "completed" files.

[1]: https://github.com/vimwiki/vimwiki

For people interested in non-Vim alternatives, Logseq and Org-mode both streamline a very similar workflow. (I’m one of those who eventually migrated from Vim to Emacs because of Org-mode, now combined with Howm-mode.)
I made a small utility to make this easier:

https://pypi.org/project/dia/

The problem of "grep but with indents" by making a shell function/script that just invokes the appropriate arcane sed commands.