shithub: svcclient

Download patch

ref: f3125a94649e1a92ec86ac08c90312c01a258e26
author: Michael Misch <michaelmisch1985@gmail.com>
date: Sat Jan 24 01:38:03 EST 2026

Initial commit

--- /dev/null
+++ b/README
@@ -1,0 +1,13 @@
+# svc/cl
+
+Interact with svc/fs 
+
+## Usage
+
+svc/cl [-n lines] service
+
+- n sets the amount of lines of context when switching to a buffer. Default is 20
+
+## Commands
+- /b <buffer> : switch to buffer 
+- /q : quit
--- /dev/null
+++ b/cl
@@ -1,0 +1,69 @@
+#!/bin/rc
+
+rfork ne
+
+fn sighup sigint sigterm {
+	if(! ~ $#svc 0)
+		unmount /mnt/$svc
+	echo 'exiting'
+}
+
+fn usage {
+	echo >[1=2] usage: cl [n lines] service
+	exit usage
+}
+
+fn setbuff {
+	if(~ $#current 0)
+		return
+	echo buffer $current > /mnt/$svc/ctl
+	label $"current@$svc
+}
+
+fn tailback {
+	if(~ $#current 0)
+		return
+	count=`{grep $current /mnt/$svc/tabs | sed 's/\[//;s/\].*//'}
+	# Any unreads plus our scrollback/context lines
+	count=`{echo $count + $lines | pc}
+	tail -^$count^f /mnt/$svc/feed
+}
+
+current=()
+lines=()
+svc=()
+
+while(~ $! -*){
+	switch($1){
+	case -n
+		lines=$1
+		shift
+	case -*
+		usage
+	}
+}
+
+svc=$1; shift
+if(~ $#lines 0)
+	lines=20
+if(~ $#svc 0)
+	usage
+# Ensure our mount is correct
+if(test -d /mnt/$svc)
+	unmount /mnt/$svc
+if(test -e /srv/$svc)
+	mount /srv/$svc /mnt/$svc
+
+list=`{cat /mnt/$svc/tabs | sed 's/\[.*\] //'}
+if(~ $#list 1)
+	current=$list(1)
+if not{
+	echo select buffer: [$list(1)]
+	if(! ~ $#list 1)
+		echo $list(2-)
+	# read in the selected buffer
+	selected=`{read}
+	echo $selected
+}
+setbuff
+tailback
--