xwmx / nb

CLI and local web plain text note‑taking, bookmarking, and archiving with linking, tagging, filtering, search, Git versioning & syncing, Pandoc conversion, + more, in a single portable script.
https://xwmx.github.io/nb
GNU Affero General Public License v3.0
6.43k stars 180 forks source link

Add a "per-day" log file mode #300

Closed voxelv closed 4 months ago

voxelv commented 5 months ago

I'm only beginning to scratch the surface of nb's features, so there might be some that aren't compatible with this idea.

I would find it useful to have a mode in nb where each new note is logged into a daily file rather than new files. Currently, a note such as nb add "This is a new note" creates a new file with the date and time it was made as the file's name. My idea would be for a single file per day to be created (if it didn't already exist) and new notes taken during that day appended to the file (with timestamps).

Perhaps this could be implemented with an environment variable such as NB_MODE_DAILY.

Currently, it looks like this:

20240129143924.md - "three"
20240129143918.md - "two"
20240129143913.md - "one"

Instead, I'd like it to look like this:

20240129.md:
  [14:39:13] one
  [14:39:18] two
  [14:39:24] three
xwmx commented 5 months ago

@voxelv That sounded relatively easy to make a plugin, so I added one with tests. Install it with:

nb plugin install https://github.com/xwmx/nb/blob/master/plugins/daily.nb-plugin

See help:

nb help daily
voxelv commented 4 months ago

Amazing!

I've tested it a bit and noticed (at least in fish shell) that nb daily "Stuff and things" results in a good entry, but nb daily Stuff and Things results in an entry containing only Stuff. I wonder if the rest of the args could just be appended as well, if the first arg doesn't match an option (such as --prev).

voxelv commented 4 months ago

I also just tried nb daily --prev 2 and got this error:

find: warning: you have specified the global option -maxdepth after the argument -type, but global options are not positional, i.e., -maxdepth affects tests specified before it as well as those specified after it.  Please specify global options before other arguments.
! Not found.
xwmx commented 4 months ago

@voxelv That feature has been added and the find issue should be resolved.

voxelv commented 4 months ago

I love it! Thanks!

novakwh commented 2 months ago

Any chance in the future this might be able to log into a daily file in a specific notebook rather than just the one you happen to be using at the moment?

novakwh commented 2 months ago

Any chance in the future this might be able to log into a daily file in a specific notebook rather than just the one you happen to be using at the moment?

Never mind, I just realized I can type the command as "notebook-name:daily" and it works as expected. Thanks!

novakwh commented 2 months ago

One more question: would it be possible to set the daily plugin to recognize the default extension setting? It seems to create the daily as .md even when the default extension is org. Thanks!