Skip to content

Instantly share code, notes, and snippets.

@fabiolimace
Created January 15, 2024 05:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fabiolimace/c9b35c2ebea5717cdcd7c6a25cd1d49d to your computer and use it in GitHub Desktop.
Save fabiolimace/c9b35c2ebea5717cdcd7c6a25cd1d49d to your computer and use it in GitHub Desktop.
Append notes to today's text file in the notes folder
#!/bin/bash
#
# Append notes to today's text file in the notes folder.
#
# Usage:
#
# $ notes # append to today's file
# this is a note
# [CTRL+D]
#
# $ notes edit # edit today's file
# $ notes show # show today's file
#
# $ ls -1 ~/Notes
# 2024-01-14.txt
#
# $ cat ~/Notes/2024-01-14.txt
# this is a note
#
# # grep -r "this" ~/Notes
# /home/user/Notes/2024-01-14.txt:this is a note
#
# Controls:
#
# * CTRL+D: confirm and append note
# * CTRL+C: cancel and don't append note
#
NOTES_BASE=~/Notes;
NOTES_FILE=$NOTES_BASE/$(date +%Y-%m-%d).txt;
[ -d "$NOTES_BASE" ] || mkdir --parents "$NOTES_BASE";
[[ -z "${1}" ]] && (cat; printf "\n\n") >> "$NOTES_FILE";
[[ ${1} =~ ^e(dit)?$ ]] && vim "$NOTES_FILE";
[[ ${1} =~ ^s(how)?$ ]] && cat "$NOTES_FILE";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment