Initial commit

This commit is contained in:
Jordan Goulder 2025-01-07 12:04:29 -05:00
commit 86d3fd0b35
2 changed files with 60 additions and 0 deletions

27
README.md Normal file
View File

@ -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.

33
daily.sh Executable file
View File

@ -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"