2
. Script to generate note files
In order to fulfill the requirements outlined in the previous section, I needed a script that could generate note files with consistent and sequential names, allowing the computer to automatically time/date-stamp them. All the note files will be named note_YY-MM-DDL.txt, where YY is a two-digit year designation, MM a two-digit (zero padded) month designation, and DD a two-digit (zero padded) day designation. The L stands for a single lower case letter, a-z. Additional date- and time-stamping occurs inside the file that is generated.
These filenames have the advantage that, no matter how many are in the same directory, they will be listed (ls) and printed (cat) in chronological order. The obvious drawback is that you may have an identically-named note file located at ../ for example. But in my experience, the pros of this convention far outweigh the cons, and I have never had a problem with notes at different locations having the same filename.
The script that accomplishes this is called newnote.sh and is executed simply like this:
./newnote.sh
For example, the first execution in the present working directory produces a file called note_21-08-05a.txt, which simply looks like this:
08/05/2021
7:13:22 PM
---------------------
---------------------
---------------------
---------------------
---------------------
---------------------
################################################################################
################################################################################
Apart from the date and time, the other auto-generated elements are simply convenient visual aids. For example, I often use the sets of thin lines
---------------------
---------------------
to set apart useful lines of code that I might want to copy/paste into my notes. (E.g. a specific set of arguments to a more complicated script.)
The utility of the pair of octothorpe lines at the bottom of the file becomes apparent when you view multiple note files at once. For example, executing again in the same directory:
./newnote.sh
produces a second note file, this time named note_21-08-05b.txt. Simply printing these two files with one command:
cat note_21-08-05a.txt note_21-08-05b.txt
produces this output:
08/05/2021
7:13:22 PM
---------------------
---------------------
---------------------
---------------------
---------------------
---------------------
################################################################################
################################################################################
08/05/2021
7:37:20 PM
---------------------
---------------------
---------------------
---------------------
---------------------
---------------------
################################################################################
################################################################################