Last active
August 19, 2017 19:26
-
-
Save kousu/463c3d2426e0e0e1791ebeeac371c241 to your computer and use it in GitHub Desktop.
Handy personal journal script
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/sh | |
# journal | |
# | |
# Usage: journal [date] | |
# | |
# Spawn your plain-text $EDITOR open to your diary. | |
# Journal files are arranged in a simple tree hiearchy by date under ~/Journal/. | |
# If date is given, it is a date string as understood by GNU date; | |
# you can say for example, | |
# journal yesterday | |
# journal "2 days ago" # to open 2 days ago | |
# journal "1 week" # to open a week in the future | |
if [ ! -z $XAUTHORITY ]; then | |
EDITOR="leafpad --jump=-1" # HACK: make sure we go to the end of the line for the journal | |
fi | |
DAY=${1:-today} | |
JOURNAL=~/Journal/`date -d "$DAY" +%Y`/`date -d "$DAY" +%m`/`date -d "$DAY" +%d`.txt | |
if [ ! -f $JOURNAL ]; then | |
cat > $JOURNAL <<EOF | |
Journal for $(date -d "$DAY" +"%A %B %d, %Y") | |
------------------------------------------ | |
EOF | |
fi | |
${EDITOR:-vi} $JOURNAL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment