-
-
Save RSNara/0efc027fda0a6be927a33ec128652d20 to your computer and use it in GitHub Desktop.
A bash function that I use to create a daily org journal.
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 | |
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