💾 Archived View for kota.nz › notes › memo captured on 2023-04-26 at 13:13:42. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2022-06-03)
-=-=-=-=-=-=-
2021/08/22
I found a neat tool called memo the other day. It's just a little notes program that integrates nicely with other unix tools. There are many like it, but this one nails the sweet spot of not too complex, but without lacking important features for me. Additionally, it's extendable via "plugins" in a clever way. If I were to write a notes program myself I would want it to look a lot like this.
Memo stores all your "memos" as markdown files in a directory and has a handful of subcommands to manipulate and create them.
new, n create memo list, l list memo edit, e edit memo cat, v view memo delete, d delete memo grep, g grep memo config, c configure serve, s start http server help, h Shows a list of commands or help for one command
I don't really use the serve command, but basically it uses go's built in webserver to host a simple html page with all your memos. You can use go's templating language to add some css and so forth if you need it. It could be useful as a quick way to share notes. You can even track your memos with git and have a little collaborative memo server.
These commands generally call external tools like your editor, grep (or it's clones), fzf (or it's clones), and like I said you can also create "plugins" to add your own subcommands. You can find two example plugins in the source's misc folder. They're named push and pull and are useful if you track your notes with git. Running memo c opens up the config.
memodir = "/home/kota/docs/memos" editor = "/bin/nvim" column = 20 width = 0 selectcmd = "fzf" grepcmd = "nvim $(rg -l ${PATTERN} ${FILES} | fzf)" memotemplate = "" assetsdir = "." pluginsdir = "/home/kota/.config/memo/plugins" templatedirfile = "" templatebodyfile = ""
The default grep command prints the search results to your terminal, I changed mine to print the results to fzf and then open my selection in my editor. I also used ripgrep, but you can use any searching tool you prefer.
Here's that rename plugin I wrote:
#!/bin/sh if [ "$1" = "-usage" ]; then echo find and rename a memo exit fi files="$(fd -t f --base-directory "$MEMODIR")" file="$(echo "$files" | fzf)" path="$MEMODIR""/""$file" printf "old: %b\n" "$file" printf "new: " read -r new newpath="$MEMODIR""/""$new" mv "$path" "$newpath" # strip extension, date, and replace hyphen with space title="$(echo "$new" | sed 's/.[^.]*$//' | cut -c 12- | tr "-" " " )" # replace first line of file with our new title sed -i "1s/.*/# $title/" "$newpath"
You can use any language you'd like, but scripting languages make the most sense. This script uses fd (a find replacement) to list my memos into fzf. Then, it shows a prompt for me to type in a new name, and finally moves the file and swaps out the markdown heading on the first line of the memo.
I'm sure emacs users are happier with org-mode, and probably most unix users make a few shell script that can do all of the above, but I was a complete mess. I had a huge notes directory tree full of duplicates, weird formats from over the years, and this was the push I needed to sort through that shit and get it all organized. Now whenever I read some interesting post, learn about a new tool, or need to jot down an idea I have a quick way to do so and search it back up later.