by dankco · 5y ago · 0 comments
I wanted to share a tool I built out of a desire to easily create and organize plain-text notes on the command line. textnote is a CLI for quickly creating, opening and managing daily plain-text notes. I built it to encourage myself to practice daily note taking by making it dead simple to open a prebuilt, templated, dated note file in Vim. I thought it would be good to share here with the HN community because it is intentionally lightweight and meant to be paired with other commandline tools (grep, fzf, etc) for additional functionality.
The key feature built into textnote that I couldn't find elsewhere is archiving. Running its archive command will consolidate notes into monthly archive summary files and (optionally) remove the original daily files to declutter and turn your notes organized records over time.
I hope you might find it useful and I'd love to take any feedback or suggestions that might come to mind!
Are you familiar with the $EDITOR and/or $VISUAL environment variables?
Text-based (i.e., CLI) applications which spawn a text editor should respect/support them as much as possible.
The options that I see for using $EDITOR are: (1) simply ignore the line option for non-vim editors, (2) add implementation for specific editors, each with their own "jump to line" argument if it exists, or (3) add an additional command line argument that passes args/flags on to the editor. Option (3) seems best to me but I do worry about the number of supported flags - it is quite a lot already! More seriously, this option could be a vector for malicious code execution.
Thanks again, really appreciate the feedback! I'd love to hear your thoughts.
[EDIT: add comment on malicious code execution]
Or you always invoke the editor as "$EDITOR +$LINE $FILE" and if someone wants to use an editor that uses different command line arguments, they have to write a wrapper shell script to rewrite it.
vim, nano, and emacs support this syntax. micro uses "micro ${FILE}:${LINE}", and subl (Mac command line tool for Sublime Text) uses it as well.
I use a simple homebrewed system for my notes too, https://github.com/d5ve/noop which is just a search/edit loop, where you look for files and add/edit them.
https://github.com/d5ve/noop started out in golang too, but I ended up shelling out for so much stuff anyway, that I rewrote it in bash.
Fortunately, for textnote I only have to shell out once to open the file. I will try hard to keep it that way, otherwise I agree with you and others that bash might be the more appropriate tool. Then again, there is functionality included that would be much more difficult to accomplish in bash (templating, archiving, configuration).
Thanks again for your comments and feedback!
Why not just perform the consolidation automatically (the first time textnote is executed after the first of the month), allowing you to do away with the subcommand?
Or perhaps make automatic consolidation configurable / optional (along with any desired default options)?