1#!/bin/sh 2 3if [ ! -S "${INSOMNIA_DIR}/usr" ]; then 4 name="$(cat "${INSOMNIA_DIR}/id" 2>/dev/null)" 5 echo "[(insomnia)]${name:+ $name}" 6 exit 7fi 8 9# Find the most recent topic change and exit. Since we don't want to10# search through the entire backlog we reverse it first by sorting it11# using the unix timestamp.12sort -k1 -r "${INSOMNIA_DIR}/out" | sed -n '13 /^[0-9][0-9]* \*\*\* ..* has set the topic to: .*$/ {14 s/^[0-9][0-9]* \*\*\* ..* has set the topic to: \(.*\)$/\1/p15 q16 }1718 /^[0-9][0-9]* \[\*\] topic for ..* is: .*$/ {19 s/^[0-9][0-9]* \[\*\] topic for ..* is: \(.*\)$/\1/p20 q21 }22'