Skip to content

Instantly share code, notes, and snippets.

@mjmckinnon
Last active October 5, 2017 22:36
Show Gist options
  • Save mjmckinnon/c6e4a6ddb709aad11eeb378ed92141ba to your computer and use it in GitHub Desktop.
Save mjmckinnon/c6e4a6ddb709aad11eeb378ed92141ba to your computer and use it in GitHub Desktop.
#!/bin/sh
clear
# Instructions:
# Step 1 - Create a new empty folder called 'MyLog' (or similar)
# Step 2 - Inside that folder drop this file called log.sh (or similar)
# Step 3 - Make the log.sh file executable
# Step 4 - Run the following commands:
# git init
# git add .
# git commit -m "MyLog Initialised"
# Step 5 - Now you have a git repo that will act as a log, to run:
# ./log.sh
#
# For more information on this idea:
# https://www.lifehacker.com.au/2013/02/how-to-use-git-as-a-running-sheet/
# TODO: Build a delete feature to remove the previous log entry
# Command would be: git reset --hard HEAD^
# Show the previous log entries
echo "\n"
git log --reverse --pretty=format:"%ad: %s"
# Helper prompt
echo "\nAdd log entries. Press Enter on a blank line to exit."
# Loop until we get nothing to add (enter on blank line)
while true
do
echo
read -p "log> " logtext
if test -z "$logtext"
then
exit 0
else
git commit --allow-empty -m "$logtext"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment