Created
January 15, 2024 05:45
-
-
Save fabiolimace/c9b35c2ebea5717cdcd7c6a25cd1d49d to your computer and use it in GitHub Desktop.
Append notes to today's text file in the notes folder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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