Second Shell Script - Autolog

I joined Cosmic Voyage a while back. I really love the system there for updating you ship’s posts. You type ’log’ at the command line and you are presented with a series of options for logging your entry.

This morning, I decided to try out something similar for logging gemini posts.

I did look at the script for the Cosmic Voyage log command, but it was a bit too complicated for me (!).

So, I tried to just put together something as simply as I could (I am still so new to the shell and I have no technical experience outside of linux).

The script just:

It seems to work okay. It was really useful learning how to search for a string with sed, and then add the entry to the next line.

Still to do:

(https://www.hughrundle.net/how-to-write-a-static-site-generator-in-30-lines-or-less/)

Anyway, here is the script if anyone’s interested:


#!/bin/sh
DIR="/home/eoin/gemini/"

[ -z "$1" ] && exit
echo "Title: "
read title
# Inserts log entry in index, under current month
sed -i "/\\$(date +'%B')/a => $1 $(date +'%Y-%d-%m') - $title" $DIR/gemlog/index.gmi

echo "Commit Message:"
read msg
# updates microlog
sed -i "9i## $(date +'%a %d %b %Y %H:%M %Z')\n$msg\n" $DIR/micro.gmi

# Inserts entry in tag section of gemlog
echo "Tag:"
read tag
[ -z $tag ] && exit

if [[ "$tag" = "Meta" ]]; then
  sed -i "/\# Meta/a => $1 $title" $DIR/gemlog/tags.gmi
elif [[ "$tag" = "Reading" ]]; then
  sed -i "/\# Reading/a => $1 $title" $DIR/gemlog/tags.gmi
elif [[ "$tag" = "Scavenge" ]]; then
  sed -i "/\# Scavenge/a => $1 $title" /$DIR/gemlog/tags.gmi
elif [[ "$tag" = "Journal" ]]; then
  sed -i "/\\$(date +'%B')/a => $1 $title" /$DIR/gemlog/tags.gmi
fi
← Gemini Capsule Update How to live →