Skip to content

Instantly share code, notes, and snippets.

@mattyza
Last active August 5, 2016 09:50
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattyza/2e35b675b1661da3538a075ec36453d8 to your computer and use it in GitHub Desktop.
Save mattyza/2e35b675b1661da3538a075ec36453d8 to your computer and use it in GitHub Desktop.

Simple iDoneThis Alternative

This simple script is for logging all of the awesome things you do every day, using Terminal, and syncing them all to Dropbox. Nifty, right?

Installation

  • Grab the idid.sh file to a directory on your computer (tested with OS X).
  • Using Terminal, in the directory where you placed idid.sh, run the following commands:
  • mv idid.sh /usr/local/bin/idid.sh
  • cd /usr/local/bin
  • chmod +x idid.sh
  • mv idid.sh idid

Usage

Once installed, you can run the idid command, from any directory on your machine, using the following format:

idid "Created an awesome script to track what I do, using Terminal." (Take note of the use of double quotes, to wrap the sentence.)

Typing idid open as your command will open the file for the current week in the nano editor.

Result

The script creates a system which stores the information in a per-week file. You'll end up with a structure as follows:

_ididthis -> 2016-week-30.md

Happy tracking!

#!/bin/sh
# Check if we have an input argument in slot $1
if [ -z "$1" ]
then
printf "What did you get done? "
read SENTENCE
else
SENTENCE=$1 # No spaces, as spaces break this statement.
fi
# What year are we in?
YEAR=$(date +"%Y")
# What week of the year are we in?
WEEK=$(date +"%U")
# What day is it, today?
DAY=$(date +"%A")
# Whatis our current timestamp?
TIMESTAMP=$(date +"%Y-%m-%d %H:%M:%S")
# Lets create the file name we'll be writing to.
FILENAME="$YEAR-week-$WEEK.md"
# Format the text to be logged.
MESSAGE="[$DAY] | $SENTENCE | $TIMESTAMP"
# Open the file for the current week, if we use the "open" command.
if [ "open" == "$SENTENCE" ]
then
# Navigate to the folder inside our Dropbox. This assumes the location of your Dropbox.
cd ~/Dropbox/_ididthis
nano "$FILENAME"
exit
fi
# Navigate to our Dropbox. This assumes the location of your Dropbox.
cd ~/Dropbox
# Make our _ididthis directory, if it doesn't exist
if [ ! -d "_ididthis" ]
then mkdir _ididthis
fi
cd _ididthis
# Make our $WEEK file, if it doesn't exist.
if [ ! -f "$FILENAME" ]
then touch "$FILENAME"
fi
# Add our idid, using the format of: [$DAY] | $SENTENCE | $TIMESTAMP.
echo "$MESSAGE" >> "$FILENAME"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment