ref: 4e4231762d9a3fad36816ec2864b2c2ddbd2e719
dir: /plumbing/
# 2024-02-20T23:16:26-05:00
# to update: cp /usr/$user/lib/plumbing /mnt/plumb/rules
editor=sam
browser=mothra
#include basic
addrelem='((#?[0-9]+)|(/[A-Za-z0-9_\^]+/?)|[.$])'
addr=:($addrelem([,;+\-]$addrelem)*)
plumb to seemail
plumb to showmail
plumb to msword
plumb to sendmail
plumb to image
plumb to postscript
plumb to edit
plumb to none
plumb to web
# have plumber run command
kind is text
data matches 'Local (.*)'
plumb to none
plumb start rc -c $1
# rtf files go to wdoc2txt
type is text
data matches '[a-zA-Z¡-0-9_\-.,/]+'
data matches '([a-zA-Z¡-0-9_\-.,/]+)\.rtf'
arg isfile $0
plumb to msword
plumb start wdoc2txt $file
# start rule for microsoft word documents without .doc suffix
type is text
dst is msword
plumb to msword
plumb start wdoc2txt $file
# email addresses get a new mail window
type is text
data matches '[a-zA-Z0-9_+.\-]+@[a-zA-Z0-9_+.\-]*'
plumb to sendmail
plumb start window rc -c '''echo % mail '''$0'; mail '$0
# games/vmac*
type is text
data matches '([.a-zA-Z¡-0-9_/+\-]*[a-zA-Z¡-0-9_/+\-])\.(bin|dsk|img|sit|rom|BIN|DSK|IMG|SIT|ROM)'
arg isfile $0
plumb to minivmac
plumb start minivmac $file
# c64
type is text
data matches '([a-zA-Z¡-0-9_\-.,/]+)\.(tap|TAP)'
arg isfile $1.$2
data set $file
plumb to none
plumb start c64 -2 $file
# gb
type is text
data matches '([a-zA-Z¡-0-9_\-.,/]+)\.(gb|GB)'
arg isfile $1.$2
data set $file
plumb to none
plumb start gb -2 -a $file
# gba
type is text
data matches '([a-zA-Z¡-0-9_\-.,/]+)\.(gba|GBA)'
arg isfile $1.$2
data set $file
plumb to none
plumb start gba -2 -a $file
# nes
type is text
data matches '([a-zA-Z!¡-0-9_\-.,/]+)\.(nes|NES)'
arg isfile $1.$2
data set $file
plumb to none
plumb start nes -2 -a $file
# snes
type is text
data matches '([a-zA-Z!¡-0-9_\-.,/]+)\.(sfc|SFC|smc|SMC)'
arg isfile $1.$2
data set $file
plumb to none
plumb start snes -2 -a $file
# md
type is text
data matches '([a-zA-Z!¡-0-9_\-.,/]+)\.(gen|GEN|md|MD)'
arg isfile $1.$2
data set $file
plumb to none
plumb start md -2 -a $file
# images/postscript/pdf/dvi/doc go to page but not over the a plumb port
# the port is here for reference but is unused
type is text
data matches '([a-zA-Z!¡-0-9_\-.,/]+)\.(jpe?g|JPE?G|gif|GIF|tiff?|TIFF?|ppm|PPM|bit|BIT|png|PNG|pgm|PGM|bmp|BMP|yuv|YUV|ps|PS|eps|EPS|pdf|PDF|dvi|DVI|doc|DOC|epub|EPUB|cb[tz]|CB[TZ]|tga|TGA)(:§([a-zA-Z¡-0-9_\-./]+))?'
arg isfile $1.$2
data set $file
attr add jump=$4
plumb to none
plumb start page -j $4 -w $file
# handle page(1) bookmark strings
type is text
data matches '(([a-zA-Z!¡-0-9_\-.,/]+)\.(ps|PS|eps|EPS|pdf|PDF|dvi|DVI|doc|DOC|epub|EPUB|cb[tz]|CB[TZ]))!(.+)'
arg isfile $1
data set $file
attr add addr=$4
plumb to none
plumb start page -wij $0 $file
# mdir individual mail message file -> new mail window for message
type is text
data matches '[a-zA-Z¡-0-9/\-]+/[0-9]+.[0-9][0-9]'
plumb to showmail
plumb start rc -c '@{rfork n; ramfs; bind -ac /tmp `{basename -d '$0'}; upas/fs -f '$0'; window -m mother -p 1}'
#plumb start rc -c '@{rfork n; ramfs; bind -ac /tmp `{basename -d '$0'}; upas/fs -f '$0'; window -m -r 4 120 750 600 upas/nedmail -s /mail/fs/mbox/1}'
# existing files, possibly tagged by line number, go to editor
type is text
data matches '([.a-zA-Z¡-0-9_/+\-]*[a-zA-Z¡-0-9_/+\-])('$addr')?'
arg isfile $1
data set $file
attr add addr=$3
plumb to edit
plumb client window $editor
# .h files are looked up in /sys/include and passed to edit
type is text
data matches '([a-zA-Z¡-0-9]+\.h)('$addr')?'
arg isfile /sys/include/$1
data set $file
attr add addr=$3
plumb to edit
plumb client window $editor
# .m files are looked up in /usr/inferno/module and passed to edit
type is text
data matches '([a-zA-Z¡-0-9]+\.m)('$addr')?'
arg isfile /usr/inferno/module/$1
data set $file
attr add addr=$3
plumb to edit
plumb client window $editor
# faces -> new mail window for message
type is text
data matches '[a-zA-Z¡-0-9_\-./]+'
data matches '/mail/fs/[a-zA-Z¡-0-9/]+/[0-9]+'
plumb to showmail
plumb start window upas/nedmail -s $0
#plumb start window facemother $0
# man index entries are synthesized
type is text
data matches '([a-zA-Z¡-0-9_\-./]+)\(([1-8])\)'
plumb start window -dx 800 -dy 600 ''man $2 $1; rc''
#plumb start rc -c 'man -b '$2' '$1'
# RFC references are looked up in /lib/rfc and passed to editor
#type is text
#data matches 'RFC ?([0-9]+)'
#arg isfile /lib/rfc/rfc$1
#data set $file
#plumb to edit
#plumb client window $editor
# RFC references are looked up in /lib/rfc and printed in a new rio window
type is text
data matches '(rfc|RFC) ?-?([0-9]+)'
plumb start window -dx 800 -dy 600 ''cat /lib/rfc/rfc$2; rc''
# start rule for images without known suffixes
dst is image
plumb to image
plumb client page -wi
# start rule for postscript without known suffixes
dst is postscript
arg isfile $data
plumb start page -w $data
type is text
data matches 'Local (.*)'
plumb to none
plumb start rc -c $1
type is text
data matches 'https?://.*\.(jpe?g|JPE?G|gif|GIF|tiff?|TIFF?|ppm|PPM|bit|BIT|png|PNG|pgm|PGM|bmp|BMP|yuv|YUV|cbz|CBZ|epub|EPUB|pdf|PDF|ps|PS)'
plumb start rc -c 'hget '''''$0''''' | page -w'
#type is text
#data matches 'https?://[w]*.?youtube.com.*'
#plumb to none
#plumb start openssh/ssh stanleylieber@holon open ''''$0''''
# am start -a android.intent.action.VIEW -n com.android.chrome/.Main -d http://google.com
# thanks, Sigrid
type is text
data matches 'https?://(www.)?youtu(.)be[^ ]+'
plumb start window pyt ''''$0''''
type is text
data matches '([a-zA-Z¡-0-9_\-.,/]+)\.(mp3|MP3|ogg|OGG|flac|FLAC|wav|WAV|au|AU|mid|MID|mus|MUS|m3u|M3U|pls|PLS)'
plumb to none
plumb start window -scroll play ''''$0''''
type is text
data matches '(file|http)s?:///?[^ ]+'
plumb to none
plumb start window -dx 800 -dy 600 mothra -a ''''$0''''
# webshit
data matches 'https?://.+|/tmp/webshit.*|[₀-₉]+|hpost.*'
plumb to webshit
plumb client window webshit
# gemini
type is text
data matches 'gemini://[^ ]+'
plumb to gemini
plumb client window gemnine -w $0