Skip to content

Instantly share code, notes, and snippets.

@RSNara
Last active April 10, 2019 09:00
Show Gist options
  • Save RSNara/0efc027fda0a6be927a33ec128652d20 to your computer and use it in GitHub Desktop.
Save RSNara/0efc027fda0a6be927a33ec128652d20 to your computer and use it in GitHub Desktop.
A bash function that I use to create a daily org journal.
#!/bin/bash
function cj() {
JOURNAL_HOME="$HOME/.journal"
FILE="$JOURNAL_HOME/$(date +%Y-%m-%d)".org
mkdir -p "$JOURNAL_HOME"
if [[ ! -f "$FILE" ]]; then
JOURNAL_COUNTER_FILE="$JOURNAL_HOME/.journal-counter"
if [[ ! -f "$JOURNAL_COUNTER_FILE" ]]; then
echo "0" > "$JOURNAL_COUNTER_FILE"
fi
NUM=$(<"$JOURNAL_COUNTER_FILE")
NUM=$((NUM+1))
echo "#+TITLE: Journal #"$NUM > "$FILE"
echo "#+AUTHOR: Ramanpreet Nara" >> "$FILE"
echo "#+DATE: $(date)" >> "$FILE"
echo "#+STARTUP: latexpreview" >> "$FILE"
echo "" >> "$FILE"
printf "* " >> "$FILE"
echo $NUM > "$JOURNAL_COUNTER_FILE"
fi
}
cj
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment