commit 508af1a4cd4debb9da3ad61afef317c818d7cb8d
parent d888d1e2b94a2446fcee20bfe67066846993bd51
Author: Jacob R. Edwards <n/a>
Date: Wed, 23 Nov 2022 17:03:59 -0600
Add journal utility scripts
These scripts make it easy to add new entries to my journal (entry),
list previous ones (jourlist and jourtail), and view them graphically
(lec). (These have been in use for a long time, but for one reason
or another [I forgot] they never got added)
Diffstat:
5 files changed, 82 insertions(+), 0 deletions(-)
diff --git a/local/bin/bin/entry b/local/bin/bin/entry
@@ -0,0 +1,35 @@
+#!/bin/sh
+# Copyright 2021 Jacob R. Edwards
+# Setup and open editor on a note.
+
+set -Ceu
+
+prefix="$HOME/own/journal"
+path="$prefix/$(date +%Y/%m/%d/%H%M)"
+date="$(date +'%F %R %z (%Z)')"
+
+rm -f "$prefix/dead.entry"
+
+test -f "$path" && {
+ echo "$path: Entry already exists" 1>&2
+ exit 1
+}
+
+mkdir -p "$(dirname "$path")"
+
+printf '.TL
+Untitled
+.AU
+Jacob R. Edwards
+.DA %s
+.PP
+' "$date" >> "$path" # append is an extra safty measure against overwriting
+
+sha=$(sha256 < "$path")
+"${EDITOR:-vi}" "$path"
+if test $sha = $(sha256 < "$path")
+then
+ mv "$path" "$prefix/dead.entry"
+ echo "No apparent change, moved to '$prefix/dead.entry' to be removed on the next invocation." 1>&2
+ exit 1
+fi
diff --git a/local/bin/bin/jourhead b/local/bin/bin/jourhead
@@ -0,0 +1,25 @@
+#!/usr/bin/awk -f
+# Copyright 2021, 2022 Jacob R. Edwards
+# Print Journal Entry Titles
+
+/^$/ { next }
+! /^\./ { nextfile }
+
+/^\.TL$/ {
+ do {
+ getline
+ } while (/^\./) # Skip potential comments
+
+ # Replace quote strings with ASCII double quote
+ if (/\\\*[QU]/)
+ gsub("\\\\\\*[QU]", "\"", $0)
+
+ # Encase superscripts in brackets
+ if (/\\\*[{}]/) {
+ gsub("\\\\\\*{", "[", $0)
+ gsub("\\\\\\*}", "]", $0)
+ }
+
+ print FILENAME, $0
+ nextfile
+}
diff --git a/local/bin/bin/jourlist b/local/bin/bin/jourlist
@@ -0,0 +1,7 @@
+#!/bin/sh
+# Copyright 2021, 2022 Jacob R. Edwards
+# List Journal Entries
+
+IFS='
+'
+jourhead $(find "$HOME"/own/journal -type f -name '[0-9][0-9][0-9][0-9]')
diff --git a/local/bin/bin/jourtail b/local/bin/bin/jourtail
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+jourlist | tail "$@"
diff --git a/local/bin/bin/lec b/local/bin/bin/lec
@@ -0,0 +1,12 @@
+#!/bin/ksh
+# last entry compile
+
+c() rm -f "$tmp"
+
+file="$(jourtail -1 | cut -d ' ' -f1)"
+
+tmp="$(mktemp -t lecXXXXXX)"
+trap c 0
+tbl < "$file" | pic | groff "$@" -ms -T ps > "$tmp"
+ps2pdf "$tmp" - | bwrite "$tmp"
+mupdf "$tmp"