Skip to content

Instantly share code, notes, and snippets.

@schollz schollz/git-journal.sh
Last active Mar 20, 2019

Embed
What would you like to do?
#!/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
You can’t perform that action at this time.