Buy me a hot chocolate! | About Me
I had a colleague at my previous role that would collect wisdom seen in Slack channels or things he learned in a text document. Whenever I asked a question he’d usually have the answer. The secret was this text document.
I had always thought: “Man, I really should have one of those.” I’d send myself notes in Slack and then one day that just disappeared. So I learned my lesson. It was only until recently that I threw this together.
The super power is being able to invoke my notes with one command and immediately be in them with my editor of choice.
I wanted this to be simple. I didn’t want to learn a new way to do notes. It needed to be simple and quick. So Org-Mode in Vim/Emacs was a no go for now.
So a simple Python script, a shell script, a shell function, and boom I can access my notes from any terminal (a place I exist in 99% of the time).
There are three files.
dt.py
– a file that has a template for the current date
that makes it easy for me to grep for things and a template for todo
items
from datetime import datetime
def print_date():
= datetime.now()
current_date = current_date.day
day = current_date.month
month = current_date.year
year print(f'day: {day} month: {month} year: {year}')
print(f'date: {current_date}')
print('TODO:')
print('- [ ]\tStuff\n'*3)
if __name__ == '__main__':
print_date()
dt.sh
– a shell script to place in one’s PATH to use
wherever
/usr/bin/python3 /home/gigatexal/tools/scripts/notes/dt.py
And then this puts it all together in my shell:
function notes(){
lvim /home/gigatexal/notes/note.md
git -C /home/gigatexal/notes add note.md
git -C /home/gigatexal/notes commit -m "stuff added"
git -C /home/gigatexal/notes push
}
#> ln -f $(readlink -f dt.sh) /home/<user>/.local/bin/dt
#> notes <-- this opens the editor with the file
And what’s really cool about this is that whenever I save and exit if there are changes they get added and pushed to a private repo – that’s what all the git stuff is after the invocation of the note
Another interesting part of this is that all my changes go into a single file, I find a single file more useful – for me.
So the flow is:
Invoke ‘notes’ from the shell <– or whatever you call the shell function
Start a new entry at the top of the file…
In Vim/NeoVim I do this by going :r! dt
which outputs
this:
day: 15 month: 2 year: 2024
date: 2024-02-15 16:37:22.078864
TODO:
- [ ] Stuff
- [ ] Stuff
- [ ] Stuff
I’m not 100% the day month year stuff is relevant but I can in my editor now do a search by date to get what I was thinking there and since it’s one document (yes, yes, fzf and other things can search all files in a folder or an entire filesystem) I can easily find things I’m looking for
Cool huh?!
Copyright Alex Narayan - 2023