diff options
Diffstat (limited to 'rc')
-rwxr-xr-x | rc/apropos | 3 | ||||
-rwxr-xr-x | rc/def | 45 | ||||
-rwxr-xr-x | rc/draw | 22 | ||||
-rwxr-xr-x | rc/here | 2 | ||||
-rwxr-xr-x | rc/kwin | 8 | ||||
-rwxr-xr-x | rc/m | 10 | ||||
-rwxr-xr-x | rc/mkdircp | 8 | ||||
-rwxr-xr-x | rc/mm | 6 | ||||
-rwxr-xr-x | rc/orig | 10 | ||||
-rwxr-xr-x | rc/out | 9 | ||||
-rwxr-xr-x | rc/patch-backup | 24 | ||||
-rwxr-xr-x | rc/plumberr | 4 | ||||
-rwxr-xr-x | rc/riostart | 8 | ||||
-rwxr-xr-x | rc/summary | 30 | ||||
-rwxr-xr-x | rc/xp | 20 |
15 files changed, 209 insertions, 0 deletions
diff --git a/rc/apropos b/rc/apropos new file mode 100755 index 0000000..a0a5c31 --- /dev/null +++ b/rc/apropos @@ -0,0 +1,3 @@ +#!/bin/rc -e +# apropos -- find man pages by name +man -w $1 | awk -F/ '{ print $NF "(" $(NF-1) ")" }' | mc @@ -0,0 +1,45 @@ +#!/bin/rc -e + +# def -- find function definition + +flagfmt=a +args='name [dir]' +if(! ifs=() eval `{aux/getflags $*} || ! ~ $#* 1 2 3){ + echo usage: $0 name [dir] >[1=2] + exit usage +} + +name=$1 +if(~ $#* 2) wdir=$2 +if not wdir=`{pwd} + +files=$wdir^/*.[ch] +if(~ $files $wdir^/'*.[ch]'){ + echo error: no c/h files found >[1=2] + exit 'not found' +} + +# ansi definition +if(~ $flaga 1){ + r=`{ + echo 'X ,x/[\n ]\**'^$name^'\(.*\)([ ]*\/\*.*\*\/)?\n{/-+=' | + sam -d $files >[2=1] | + awk -F'[ ;]' ' + /^ -\. / { file = $3; next } + /^ - / { file = $4; next } + { print file ":" $1; exit } + '} +} + +# style(1) definition +if not{ + r=`{grep -n '^'^$name^'\(' $files | awk -F: '{print $1 ":" $2; exit}'} +} + +# success +if(! ~ $r '') + echo $r + +# try to find macro instead +if not + grep -n '^#define[ ]'^$name^'\(' $files | awk -F: '{print $1 ":" $2; exit}' @@ -0,0 +1,22 @@ +#!/bin/rc + +# draw -- run program in window system's namespace + +if(~ $wsys ''){ + echo $0: '$wsys' not defined >[1=2] + exit 'wsys not defined' +} + +flagfmt='a args' +args='command ...' +if(! ifs=() eval `{aux/getflags $*}){ + aux/usage + exit usage +} + +rfork n +unmount /mnt/acme /dev >[2]/dev/null +unmount $wsys /dev >[2]/dev/null +mount $wsys /mnt/wsys 'new '$flaga +bind -b /mnt/wsys /dev +exec $* @@ -0,0 +1,2 @@ +#!/bin/rc +exec window -cd `{pwd} $* @@ -0,0 +1,8 @@ +#!/bin/rc -e + +# kwin -- show kernel messages + +echo bottom > /dev/wctl +echo scroll > /dev/wctl +echo -n errors > /dev/label +cat /dev/kprint @@ -0,0 +1,10 @@ +#!/bin/rc -e +# m -- open man page(s) for command +m=`{apropos $1} +n=() +for(p in $m) + if(~ $p *'(1)' *'(4)') + n=($n $p) +if(~ $#n 0) + exit 'no manual page' +plumb $n diff --git a/rc/mkdircp b/rc/mkdircp new file mode 100755 index 0000000..2236f24 --- /dev/null +++ b/rc/mkdircp @@ -0,0 +1,8 @@ +#!/bin/rc -e +if(! ~ $#* 2){ + echo usage: $0 fromdir todir >[1=2] + exit usage +} +if(! test -d $2) + mkdir $2 +exec dircp $1 $2 @@ -0,0 +1,6 @@ +#!/bin/rc -e +# mm -- multi-man +m=`{apropos $1} +if(~ $#m 0) + exit 'no manual page' +plumb $m @@ -0,0 +1,10 @@ +#!/bin/rc +ifs=' +' + +if(! test -d /n/sources/plan9){ + rfork n + 9fs sources +} + +exec plumb /n/sources/plan9`{cleanname -d `{pwd} $1} @@ -0,0 +1,9 @@ +#!/bin/rc +if(~ $#* 0) + f=8.out +if not + f=$1 +if(test -e $f) + exec window -cd `{pwd} rc -c 'plumber; exec '^$f +echo error: $f does not exist >[1=2] +exit 'file not found' diff --git a/rc/patch-backup b/rc/patch-backup new file mode 100755 index 0000000..55d852e --- /dev/null +++ b/rc/patch-backup @@ -0,0 +1,24 @@ +#!/bin/rc -e + +if(! test -d /n/sources/patch){ + rfork n + 9fs sources +} + +rsys=`{ndb/query ipnet plan9 cifs} +if(! test -d /n/$rsys/misc){ + if(ip/ping -n 1 '$cifs' >/dev/null){ + rfork n + cifs -m /n/$rsys '$cifs' + } + if not{ + echo $rsys not available >[1=2] + exit 'destination not available' + } +} + +if(! test -d /n/$rsys/misc/9patch) + mkdir /n/$rsys/misc/9patch + +echo dircp /n/sources/patch /n/$rsys/misc/9patch +exec dircp /n/sources/patch /n/$rsys/misc/9patch diff --git a/rc/plumberr b/rc/plumberr new file mode 100755 index 0000000..8f142be --- /dev/null +++ b/rc/plumberr @@ -0,0 +1,4 @@ +#!/bin/rc -e +cat > /tmp/plumberr +if(! ~ `{ls -l /tmp/plumberr | awk '{print $6}'} 0) + B /tmp/plumberr diff --git a/rc/riostart b/rc/riostart new file mode 100755 index 0000000..9812b84 --- /dev/null +++ b/rc/riostart @@ -0,0 +1,8 @@ +#!/bin/rc +window 0,224,161,347 winwatch -r 1000 -e '^(winwatch|stats|errors)' +window 0,113,161,230 kwin +window 0,0,161,117 stats -lmisce +window -miny 130 + +# run a system shell on the serial console +~ $#console 0 || window -scroll console diff --git a/rc/summary b/rc/summary new file mode 100755 index 0000000..b527afd --- /dev/null +++ b/rc/summary @@ -0,0 +1,30 @@ +#!/bin/rc -e + +flagfmt='o,h,x,a' +if(! ifs=() eval `{aux/getflags $*}){ + aux/usage + exit usage +} +if(~ $#flago$#flagh$#flagx 000){ + flago=1 + flagh=1 +} + +cat $home/notes | awk ' + /^ o / { o = o $0 "\n"; mode = "o"; next } # important + /^ - / { h = h $0 "\n"; mode = "h"; next } # normal + /^ x / { x = x $0 "\n"; mode = "x"; next } # done + /^ / { + if (! ENVIRON["flaga"]) next + if (mode == "o") o = o $0 "\n" + if (mode == "h") h = h $0 "\n" + if (mode == "x") x = x $0 "\n" + next + } + { mode = "" } + END { + if (ENVIRON["flago"]) printf "%s", o + if (ENVIRON["flagh"]) printf "%s", h + if (ENVIRON["flagx"]) printf "%s", x + } +' @@ -0,0 +1,20 @@ +#!/bin/rc -e + +# xp -- safer and more useful cp +# for copying directories, use dxp (or perhaps -r?) + +flagfmt='t directory' +args='files ... | from to' +if(! ifs=() eval `{aux/getflags $*} || ~ $#* 0){ + aux/usage + exit usage +} + +if(~ $flagt '') { + if(! ~ $#* 2){ + echo must be two arguments only without -t >[1=2] + aux/usage + exit usage + } + exec cp $1 $2 +} |