aboutsummaryrefslogtreecommitdiffstats
path: root/_tj_openbsd
diff options
context:
space:
mode:
authorMatthew Lemon <chaffinach+git@protonmail.ch>2022-04-19 11:11:59 +0100
committerMatthew Lemon <chaffinach+git@protonmail.ch>2022-04-19 11:11:59 +0100
commit1ca23d7427d216737eb62160dcc60cdd6ca28673 (patch)
treed5d8fd9fde24eddfbf803728f4d2266975790707 /_tj_openbsd
parent401b29df7d137747b289e0463e329aa64cb074c2 (diff)
creating bsd-versions of bash scripts
Diffstat (limited to '')
-rwxr-xr-x_tj_openbsd27
1 files changed, 27 insertions, 0 deletions
diff --git a/_tj_openbsd b/_tj_openbsd
new file mode 100755
index 0000000..7b97641
--- /dev/null
+++ b/_tj_openbsd
@@ -0,0 +1,27 @@
+#!/usr/local/bin/bash
+
+# Our target file
+TODAY_JOURNAL=~/Notes/journal/$(date +\%Y-\%m-\%d).md
+
+# Test whether it already exisits or not
+if [[ -a $TODAY_JOURNAL ]]
+then
+ while read -r line
+ do
+ JLINE="- $(date +'%H:%M'): $line"
+ echo "$JLINE" >> "$TODAY_JOURNAL"
+ done < "${1:-/dev/stdin}"
+else
+ touch "$TODAY_JOURNAL"
+ header_date="$(date +'%A %d %b %Y')"
+ { echo -e "# $header_date\n"
+ echo -e "## Journal\n"
+ } >> "$TODAY_JOURNAL"
+ while read -r line
+ do
+ JLINE="- $(date +'%H:%M'): $line"
+ echo "$JLINE" >> "$TODAY_JOURNAL"
+ done < "${1:-/dev/stdin}"
+fi
+
+