💾 Archived View for text.adventuregameclub.com › tech › delightful-notes-with-bash.gmi captured on 2023-05-24 at 17:46:47. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2022-03-01)
-=-=-=-=-=-=-
There's a really great script that I use a lot. It's called "notes". It's a nice little bash script that helps you write, organize, and search through a directory of simple text-based notes.
When you want to make a note, you just call it with something like:
notes n recipe/pancake
Notes will fire up vim (or whatever text editor you configure it to use) so you can create /home/username/sync/notes/recipe/pancake.txt
So notes saves you a little bit of typing here, since you don't have to specify the full path. Of course, the path above isn't so bad if you use ~/ instead of /home/username, but notes makes it even faster.
Notes has some autocomplete files in the git repository (I wrote the one for the fish shell), so things can be even handier. I can type 'notes o pan[tab]' and fish shell will give me 'recipe/pancake' as one of the options. It's pretty magical sometimes. I don't know how good the bash autocompletions are, but fish shell is great for this kind of stuff.
If you make a new note in a sub-directory that doesn't exist (e.g. notes n subdir/doesnt/exist/mynote), notes is smart enough to create those directories for you.
Of course, everything notes can you, you can do straight from the command line; it just makes things a little faster.
Notes doesn't just make creating (n for new) or opening (o for open) notes a little faster. It'll also make searching for notes a little faster.
You can also move with 'notes mv', cat with 'notes cat', etc. If you know these tools from the command line, then the commands are familiar and intuitive. And if you're the type of person who uses this sort of script, then you'll probably find it pretty easy to hack the script to change its behavior.
Aside from writing the fish autocompletions, I've got some other hacks I've made to notes, and one of these days, I might start submitting some pull requests for some of it.
One of the things I do, is I use notes to write these posts. I have a subdirectory in my notes file called 'public' and I wrote a little script to compile the articles in that directory into this site. Since I put my notes in a synced directory, I can notes or posts from any of my other computers.
By default, notes expects you to configure it with a file extension. Before, I discovered gemini, I was using .md for all my notes so that vim would use markdown syntax highlighting. But for my public directory, I wanted the extension to be .gmi, so I hacked the script so it'll make .gmi files in the 'public' directory, but .md files elswhere.
The way I did this has some potential. When I create or open a note in any subdirectory, notes will look for hidden config files in all the parent directories and read them in oder. So config options are all inherited from the default config file, but if you start working in the 'widgets' subdirectory, it'll import any settings in the 'widgets/.notes-config' file. And if you're working in 'widgets/sprockets', it'll read in the hidden configs from 'widgets' and then 'widgets/sprokets'. I guess it's like cascading style sheets, but cascading config files.
I don't really use this for anything other than changing the extension to .gmi in the 'public' directory, but this opens the door for creating some interesing behavior.
_______________ < $ fortune -os > --------------- \ \ .--. |o_o | |:_/ | // \ \ (| | ) /'\_ _/`\ \___)=(___/
✍️ Last Updated: 2021-06-09