I take notes with the script below, publishing to Git lol. My window manager (Sway) runs it in a terminal on-login
Respecting "$EDITOR", opens 'this week' and 'last week' in tabs:
#!/bin/bash
SCRIPT_NAME=$(basename "$0")
if pgrep -f "$SHELL.*$SCRIPT_NAME" | grep -v $$ > /dev/null; then
echo "The notes are already being edited elsewhere."
exit 1
fi
NOTE_DIR="${NOTE_DIR:-${HOME}/notes}"
CURRENT_NOTE=$(date +%Y-week%V)
LAST_WEEK_NAME=$(date -d '7 days ago' +%Y-week%V)
NOTE_PATHS=("$NOTE_DIR/$CURRENT_NOTE" "$NOTE_DIR/$LAST_WEEK_NAME")
EDITOR="${EDITOR:-vim}"
if [[ $EDITOR == *vim* ]]; then
# Run the vim-like editor with tabs
$EDITOR -c ':tab all' "${NOTE_PATHS[@]}"
else
# Run the editor without vim tab arg; assume array is fine
$EDITOR "${NOTE_PATHS[@]}"
fi
Respecting "$EDITOR", opens 'this week' and 'last week' in tabs:
Can choose where the notes go with "$NOTE_DIR"