Created
March 9, 2023 08:14
-
-
Save erikh/bbb9979582f8f3eaf9e4a3e68f391cc9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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