|
|
|
|
|
by aedocw
1370 days 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
}
|
|
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