For a while now, i've had those two lines in my i3 config
bindsym $mod+J exec subl ~/Documents/Journal/$(date +%Y%m%d).md
bindsym $mod+B exec subl ~/projects/lecaro.me/src/$(date +%Y%m%d).md
They let me quickly start a note or blog post with a simple keyboard shortcut.
However, I've found that renaming the file to add a title would make my life easier when scrolling through blog and notes.
So, i've replaced it with these lines
bindsym $mod+J exec ~/projects/bins/today.sh ~/Documents/Journal/
bindsym $mod+B exec ~/projects/bins/today.sh ~/projects/lecaro.me/src/
And added these lines of bash (thanks ChatGPT) in ~/projects/bins/today.sh
#!/bin/bash
# Check if the directory parameter is provided
if [ -z "$1" ]; then
echo "Usage: $0 /path/to/journal/directory/"
exit 1
fi
# Set the directory where the journal files are stored
JOURNAL_DIR="$1"
# Ensure the directory path ends with a slash
JOURNAL_DIR="${JOURNAL_DIR%/}/"
# Get today's date in the format YYYYMMDD
TODAYS_DATE=$(date +%Y%m%d)
# Search for a file in the journal directory that starts with today's date
MATCHING_FILE=$(ls $JOURNAL_DIR$TODAYS_DATE*.md 2>/dev/null | head -n 1)
# Check if a matching file was found
if [[ -n "$MATCHING_FILE" ]]; then
# Open the matching file with Sublime Text
subl "$MATCHING_FILE"
else
# If no matching file is found, open the standard file
subl "${JOURNAL_DIR}${TODAYS_DATE}.md"
fi
Now, if I rename the file (but keep the prefix), it will still open when pressing window+B or window+J later that day.