Last active
August 28, 2021 13:27
-
-
Save rickumali/62403ed980b923db1269909bdef99057 to your computer and use it in GitHub Desktop.
Small BASH function to enter a diary entry into a timestamped diary file (one file per day)
This file contains hidden or 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
# This bash function makes a diary command. | |
# All diary entries are kept in $HOME/diary. Each diary file represents a day | |
# and the filename is YYYYMMDD.txt | |
# Each diary entry is preceded by a timestamp. If the diary file doesn't exist, | |
# the command first makes the diary file, then it appends the timestamp. If the | |
# diary file exists, then it only appends the timestamp. | |
# The diary file is edited by vim. | |
diary () { | |
filename=$HOME/diary/`date +"%Y%m%d.txt"`; | |
if [ ! -f $filename ]; then | |
date +"%m/%d/%Y%n%n%l:%M %p%n%n" > $filename | |
else | |
date +"%n%l:%M %p%n%n" >> $filename | |
fi | |
vim + $filename | |
clear | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment