From 86d3fd0b35105373170361968f4fc7be4b8b4b1e Mon Sep 17 00:00:00 2001 From: Jordan Goulder Date: Tue, 7 Jan 2025 12:04:29 -0500 Subject: [PATCH] Initial commit --- README.md | 27 +++++++++++++++++++++++++++ daily.sh | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 README.md create mode 100755 daily.sh diff --git a/README.md b/README.md new file mode 100644 index 0000000..ec1f173 --- /dev/null +++ b/README.md @@ -0,0 +1,27 @@ +# daily.sh + +This is a simple bash script for quickly taking notes from the terminal. + +## Requirements + - Bash shell + - vim + +## Installation + +1. Copy `daily.sh` to a directory that is in your `$PATH`. + ```` + $ cp daily.sh "$HOME/bin" + ```` + +2. Change the permissions on the script, so that it is executable. + ```` + $ chmod +x "$HOME/bin/daily.sh" + ```` + +## Usage + +Just type `daily.sh`, and it will open up today's note for editing. + +Notes are stored in `$HOME/.local/daily`. + +A new note file is created for each day. diff --git a/daily.sh b/daily.sh new file mode 100755 index 0000000..7965a37 --- /dev/null +++ b/daily.sh @@ -0,0 +1,33 @@ +#!/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" \ No newline at end of file