Skip to content

Instantly share code, notes, and snippets.

@schollz
Last active March 20, 2019 14:49
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save schollz/27b4ffe562b0b74bf8ee1e8055680d22 to your computer and use it in GitHub Desktop.
Save schollz/27b4ffe562b0b74bf8ee1e8055680d22 to your computer and use it in GitHub Desktop.
#!/bin/sh
# Install into /usr/local/bin
# Make an entry using
# git-journal.sh
# Read the entries using
# git-journal.sh read
#
# Inspired by https://www.reddit.com/r/programming/comments/2951ma/jrnl_the_command_line_journal/ciif8jl/
# Enjoy!
JOURNAL="${HOME}/.journal"
REPO="git@github.com:schollz/demo3.git"
GITOPTS="--git-dir=${JOURNAL} --work-tree=${JOURNAL}"
if [ ! -d "${JOURNAL}" ]; then
git init --quiet --bare --shared=0600 ${JOURNAL} && git $GITOPTS remote add origin ${REPO}
fi
git $GITOPTS pull origin master
if [ $# -eq 0 ]; then
git $GITOPTS commit --allow-empty --quiet
git $GITOPTS push origin master
else
git $GITOPTS log --pretty=tformat:'%Cgreen%ar %Cblue%s%Creset %b'
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment