Last active
December 20, 2015 08:09
-
-
Save brandonpittman/6098342 to your computer and use it in GitHub Desktop.
Sends dayfiles, weekfiles, and monthfiles to DayOne for logging.
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
#!/bin/bash | |
# I use an elaborate system of "dayfile-#{date}" along with monthfile and | |
# weekfile to track my goals. I then log them in Day One. | |
# Sets the time you want to do the logging at. The "10#" prevents the shell from lopping off leading 0s." | |
let cutoff="10#$(date +"%H%M")" | |
if (($cutoff > 2349)) | |
then | |
# This is where entries are entered normally. | |
currentdate=$(date "+%Y-%m-%d") | |
wkg="$HOME/Dropbox/Documents/Markdown" | |
dayfile="$wkg/dayfile-$(date "+%Y-%m-%d").md" | |
if [ -f $dayfile ] | |
then | |
/usr/local/bin/dayone new < $dayfile | |
rm $dayfile | |
fi | |
weekdate=$(date -v-sat "+%Y-%m-%d") | |
weekfile="$wkg/weekfile-$(date -v -sun +"%Y-%m-%d").md" | |
if [ $currentdate == $weekdate ] | |
then | |
if [ -f $weekfile ] | |
then | |
/usr/local/bin/dayone -d="$(date -v -sun +"%m/%d/%Y") 11:50PM" new < $weekfile | |
rm $weekfile | |
fi | |
fi | |
monthdate=$(date -v+1m -v1d -v-1d "+%Y-%m-%d") | |
monthfile="$wkg/monthfile-$(date "+%Y-%m").md" | |
if [ $currentdate == $monthdate ] | |
then | |
if [ -f $monthfile ] | |
then | |
/usr/local/bin/dayone -d="$(date -v 1d "+%m/%d/%Y") 11:50PM" new < $monthfile | |
rm $monthfile | |
fi | |
echo "Today's files have been processed." | |
fi | |
else | |
# This is where the missed entries are entered. | |
currentdate=$(date -v -1d "+%Y-%m-%d") | |
wkg="$HOME/Dropbox/Documents/Markdown" | |
fixdate= | |
dayfile="$wkg/dayfile-$(date -v -1d "+%Y-%m-%d").md" | |
if [ -f $dayfile ] | |
then | |
/usr/local/bin/dayone -d="$(date -v -1d +"%m/%d/%Y") 11:50PM" new < $dayfile | |
rm $dayfile | |
fi | |
weekdate=$(date -v-sat "+%Y-%m-%d") | |
weekfile="$wkg/weekfile-$(date -v -1d -v -sun +"%Y-%m-%d").md" | |
if [ $currentdate == $weekdate ] | |
then | |
if [ -f $weekfile ] | |
then | |
/usr/local/bin/dayone -d="$(date -v -1d -v -sun +"%m/%d/%Y") 11:50PM" new < $weekfile | |
rm $weekfile | |
fi | |
fi | |
monthdate=$(date -v -1d -v+1m -v1d -v-1d "+%Y-%m-%d") | |
monthfile="$wkg/monthfile-$(date -v -1d "+%Y-%m").md" | |
if [ $currentdate == $monthdate ] | |
then | |
if [ -f $monthfile ] | |
then | |
/usr/local/bin/dayone -d="$(date -v -1d "+%m/%d/%Y") 11:50PM" new < $monthfile | |
rm $monthfile | |
fi | |
fi | |
echo "Yesterday's files have been processed." | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment