summaryrefslogtreecommitdiff
path: root/rc
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2021-01-31 14:14:05 +0000
committerJohn Ankarström <john@ankarstrom.se>2021-01-31 14:14:05 +0000
commitd325d2226cf55b63037dc62cefb7fa952d770d50 (patch)
tree9b88c71dc9a286cb8f9a4c0f40d42b7f55de5f38 /rc
parent01d70ec025ac617b1f74a7c8ccb2ed8bc120ca59 (diff)
downloadplan9-d325d2226cf55b63037dc62cefb7fa952d770d50.tar.gz
Bind $home/bin/rc to rc/ instead of ./
Diffstat (limited to 'rc')
-rwxr-xr-xrc/apropos3
-rwxr-xr-xrc/def45
-rwxr-xr-xrc/draw22
-rwxr-xr-xrc/here2
-rwxr-xr-xrc/kwin8
-rwxr-xr-xrc/m10
-rwxr-xr-xrc/mkdircp8
-rwxr-xr-xrc/mm6
-rwxr-xr-xrc/orig10
-rwxr-xr-xrc/out9
-rwxr-xr-xrc/patch-backup24
-rwxr-xr-xrc/plumberr4
-rwxr-xr-xrc/riostart8
-rwxr-xr-xrc/summary30
-rwxr-xr-xrc/xp20
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
diff --git a/rc/def b/rc/def
new file mode 100755
index 0000000..09a3f0c
--- /dev/null
+++ b/rc/def
@@ -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}'
diff --git a/rc/draw b/rc/draw
new file mode 100755
index 0000000..f450741
--- /dev/null
+++ b/rc/draw
@@ -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 $*
diff --git a/rc/here b/rc/here
new file mode 100755
index 0000000..c8199e8
--- /dev/null
+++ b/rc/here
@@ -0,0 +1,2 @@
+#!/bin/rc
+exec window -cd `{pwd} $*
diff --git a/rc/kwin b/rc/kwin
new file mode 100755
index 0000000..2448503
--- /dev/null
+++ b/rc/kwin
@@ -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
diff --git a/rc/m b/rc/m
new file mode 100755
index 0000000..1da3add
--- /dev/null
+++ b/rc/m
@@ -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
diff --git a/rc/mm b/rc/mm
new file mode 100755
index 0000000..a0aaca7
--- /dev/null
+++ b/rc/mm
@@ -0,0 +1,6 @@
+#!/bin/rc -e
+# mm -- multi-man
+m=`{apropos $1}
+if(~ $#m 0)
+ exit 'no manual page'
+plumb $m
diff --git a/rc/orig b/rc/orig
new file mode 100755
index 0000000..df991ff
--- /dev/null
+++ b/rc/orig
@@ -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}
diff --git a/rc/out b/rc/out
new file mode 100755
index 0000000..71fb5f0
--- /dev/null
+++ b/rc/out
@@ -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
+ }
+'
diff --git a/rc/xp b/rc/xp
new file mode 100755
index 0000000..07c637f
--- /dev/null
+++ b/rc/xp
@@ -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
+}