3 ms·
I've got a few zsh functions that let me type "note" which creates a file named todays date (if it doesn't exist), inserts a timestamp, and opens it in vim. Whe
by aedocw 4y ago
I've got a few zsh functions that let me type "note" which creates a file named todays date (if it doesn't exist), inserts a timestamp, and opens it in vim. When I exit vim, the notes directory is committed to git then pushed up. This lets me keep my notes directory in sync across machines, and available via web (gitea).
note () {
DATE=`date +"%Y%m%d"`
TS=`date +"%Y%m%d %H:%M:%S"`
FILE=$HOME/Documents/notes/$DATE.txt
notegitpull
echo $TS >> $FILE
vi $FILE
notegitpush
}
notegitpull () {
pushd $HOME/Documents/notes
if ping -c 1 git.server &> /dev/null
then
git pull
else
echo "Offline, not pulling changes"
fi
popd
}
notegitpush () {
pushd $HOME/Documents/notes
git pull
git add \*
git commit -m "Autocommit due to edit of $FILE"
if ping -c 1 git.server &> /dev/null
then
git push origin main
else
echo "Offline, not pushing changes up"
fi
popd
}
- ehnto 4y agoI have something similar, I made it check for a .notes folder in the current working directory so that I can have per-project notes just by adding that folder in first. I want to add custom filenames as I'm finding that easier to mentally keep track of, like "integration-bug-factfinding.note" is a little easer to find again than "12-22-2022.note". Currently I have these commands: note //Adds a note to the current days notefile, in the current directory's .notes folder if present or ~/.notes if not edit-note //Opens the same notefile as above in a text editor notes //Concats todays notefiles echos displays them all-notes //Concats all notes ever and echos them, useful to grep for keywords across my history of notes