daily-sh/daily.sh
2025-01-07 12:04:29 -05:00

33 lines
891 B
Bash
Executable File

#!/bin/env bash
# This is a simple bash script for quickly taking notes from the terminal.
# Just type `daily` and it will open up today's note for editing.
# Grab the current date
CUR_DAY=$(date +%Y-%m-%d)
# Get the current time
CUR_TIME=$(date '+%H:%M %Z')
# Get the directory where notes are going to be stored
NOTE_DIR=$(echo "$HOME/.local/daily")
# Ensure the note directory is created
mkdir -p "$NOTE_DIR"
# Get the note file name
NOTE_FILE="$NOTE_DIR/$CUR_DAY.md"
# Ensure that the note file for today is created
touch "$NOTE_FILE"
# Check to see if the note is empty,
# and if it is add a heading for today's date
[ -s "$NOTE_FILE" ] || echo -e "# $CUR_DAY\n" >> "$NOTE_FILE"
# Add a new entry for the current time
echo -e "\n## $CUR_TIME\n\n" >> "$NOTE_FILE"
# Open today's file for editing.
# You do use vim for editing...right?
vim "+normal G$" +startinsert "$NOTE_FILE"