3 ms·
Hey Everyone, 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 quickl
by dankco 6y ago
Hey Everyone,
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!
- jxy 6y agovi "$NOTEDIR/$(date '+%Y%m%d.txt')"
- d5ve 6y agoThat looks neat, cheers dankco! I think there is a lot of room for these lightweight text-first systems. I use a simple homebrewed system for my notes too, https://github.com/d5ve/noop 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 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.
- pforret 6y agoPure bash is indeed a good choice for this kind of application. I developed something similar, with some more functionality (and definitely more LoC :-) ) https://github.com/pforret/note https://github.com/pforret/note
- dankco 6y agoThanks, d5ve! I will check out your REPL approach, that sounds interesting. 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!
- jlgaddis 6y ago> Currently, Vim is the only supported text editor. 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.
- kesor 6y agonot if they use the editor specific features like jumping to a specific line in the text
- dankco 6y agoThanks for the feedback! I agree with you in general and considered supporting $EDITOR. The problem is that I wanted to support always opening on a specific line, because it quickly became annoying starting at the top of the file and always scrolling/jumping. 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]
- hibbelig 6y agoYou could support a variable $TEXTNOTE_EDITOR and it contains a string with placeholders for line number and file name. 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.
- dankco 6y agoI have released v1.1.0 with support for $EDITOR. While textnote will work with any editor, the ability to open on a specific line is currently supported for vi/vim, emacs, neovim, and nano. Thanks again for your feedback, which lead to this improvement!
- jlgaddis 6y ago> ... and archive for consolidating notes into monthly archive files. 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)?
- dankco 6y agoOP here, thanks for your suggestion! I considered doing exactly that: automatic archiving. The problem I see is that I want archiving to also "clean up" (that is, delete) the daily notes that it has consolidated and I worry about performing destructive actions such as deletes on an automated basis. For this reason, I chose to leave it in the users hands. I also worried about the possibility (albeit unlikely) for a race condition where a file you are manually opening is deleted out from under you. I'd love to hear any thoughts you might have though in light of these concerns. I'm definitely open to adapting the tool. Appreciate your feedback!
- dankco 6y agoI also realized that automating the archival process could be done using a cron job or something similar to call textnote's archive command.