config

OpenBSD system configuration
git clone git://jacobedwards.org/config
Log | Files | Refs | README

commit 7b651fea375559c9bc28fe9e72b360df5d5e4767
parent bf1a2451f5afe3edf57dd7f492b3de4e67105b44
Author: Jacob R. Edwards <jacob@jacobedwards.org>
Date:   Sat, 13 May 2023 13:26:44 -0700

Add the thread script to help with mmh(1) threads

It simply provides a scan, next, and previous function for the
current thread.

Diffstat:
Alocal/bin/bin/thread | 52++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 52 insertions(+), 0 deletions(-)

diff --git a/local/bin/bin/thread b/local/bin/bin/thread @@ -0,0 +1,52 @@ +#!/bin/sh +# Copyright 2023 Jacob R. Edwards <jacob@jacobedwards.org> +# A script to work with mmh(1) threads +# +# It basically provides a scan, next, and prev command for within +# the current thread. In the future it may add the ability to go +# to the next or previous thread, but I don't know what those +# commands will be called now that next and prev are already used. +# (Perhaps Next and Prev?) + +usage() { + name="${0##*/}" + + echo "${1:+"error: $1 +"}usage: $name + $name next + $name prev" 1>&2 + exit 1 +} + +list() { + echo '%(msg)%<(cur)%(putstr) cur%>' | pick -form /dev/stdin "$@" +} + +tscan() { + pick -thread c | xargs scan +} + +tnext() { + list -thread c | awk 'NF > 1 { getline; print; exit }' | + xargs show +} + +tprev() { + list -thread c | awk 'NF > 1 { print last; exit } { last = $0 }' | + xargs show +} + +case $# in +(0) + f=tscan ;; +(1) + case "$1" in + (next) f=tnext ;; + (prev) f=tprev ;; + (*) usage "'$1': Invalid command" + esac ;; +(*) + usage 'Too many arguments' +esac + +$f