A simple, command-line journaling system that automatically creates, structures, and backs up your daily entries to a Git repository. Never miss an entry, and keep your thoughts organized and safe.
- Automatic File Creation: A single command creates a new, dated journal entry.
- Structured Template: Each entry starts with a clean, pre-defined Markdown template (Morning, Afternoon, Night, Takeaway).
- Organized Folders: Entries are automatically saved into YEAR_MONTH folders (e.g., ~/journal/2025_10).
- Instant Editing: The new journal file opens immediately in VS Code, ready for you to start writing.
- Daily Automated Backups: A cron job automatically commits and pushes your journal to a remote Git repository (like GitHub) every night.
This system uses two core scripts:
journal.sh: The main script for creating entries.
- It determines the correct folder and filename for the day.
- It creates the directory if it doesn't exist.
- It populates the new Markdown file with a formatted date and the standard template.
- It opens the file in VS Code using the code command.
push-journal.sh: The backup script.
- It navigates to the journal directory.
- It adds all new or modified files.
- It creates a commit with a message like "Journal entry for 2025-10-10".
- It pushes the commit to the main branch of your remote repository.
A cron job is used to schedule push-journal.sh to run automatically at a set time every day.
Follow these steps to get your automated journal up and running.
Prerequisites
- A Unix-like terminal (Linux, macOS, WSL on Windows).
- Git installed.
- Visual Studio Code installed, with the code command available in your PATH.
Step 1: Set Up the Git Repository First, prepare your local directory and link it to a remote repository on GitHub, GitLab, or another service.
cd ~
mkdir journal
cd journalgit init
git branch -M maingit remote add origin [email protected]:YOUR_USERNAME/YOUR_REPOSITORY.gitStep 2: Add and Prepare the Scripts Place the journal.sh and push-journal.sh scripts in a convenient location, such as your home directory (~/).
Make them executable:
chmod +x ~/journal.sh
chmod +x ~/push-journal.shStep 3: (Optional) Create a Quick Alias
For easy access, create an alias for the journal script in your shell's configuration file (~/.bashrc, ~/.zshrc, etc.).
alias journal='bash ~/journal.sh'
# Reload your shell configuration
source ~/.bashrcNow you can simply type journal to create a new entry.
Step 4: Schedule the Daily Backup Set up a cron job to run the push script automatically.
- Open the crontab editor:
crontab -e
- Add the following line to the file. This example will run the backup every day at 11:00 PM (23:00).
0 23 * * * /bin/bash $HOME/push-journal.shSave and exit the editor.
βοΈ Daily Usage
- Open your terminal.
- Run the command journal (or bash ~/journal.sh if you skipped the alias).
- Your new journal entry will open in VS Code. Write your thoughts.
- That's it! Your work will be automatically backed up at night.
$( date '+%A, %B %d, %Y' )
## Morning
-
## Afternoon
-
## Night
-
## Takeaway/Lesson
-Happy Journaling!
- took inspiration from this blogpost