Skip to content

Instantly share code, notes, and snippets.

@erikh
Created March 9, 2023 08:14
Show Gist options
  • Save erikh/bbb9979582f8f3eaf9e4a3e68f391cc9 to your computer and use it in GitHub Desktop.
Save erikh/bbb9979582f8f3eaf9e4a3e68f391cc9 to your computer and use it in GitHub Desktop.
# import it into your profile, and create a git repository.
# then run `journal` in the repository. it will automatically
# create a dated filename (appending a number if it already
# exists), open your editor to it, and when you save and
# quit, it'll push it to your git remote.
journal () {
if [ ! -d .git ]
then
echo "Please initialize this directory with git" >&2
return 1
fi
i=1
fn=$(date +"%Y-%m-%d.md")
while [ -f $fn ]
do
i=$(($i + 1))
fn=$(date +"%Y-%m-%d.$i.md")
done
nvim $fn
git add "$fn"
git commit -s -m "$fn"
git push origin main
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment