aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbin/92
-rwxr-xr-xbin/doctype2
-rwxr-xr-xbin/man120
-rwxr-xr-xbin/page53
-rwxr-xr-xbin/web71
5 files changed, 242 insertions, 6 deletions
diff --git a/bin/9 b/bin/9
index ff1a928d..f2c4f42e 100755
--- a/bin/9
+++ b/bin/9
@@ -1,6 +1,6 @@
#!/bin/sh
-export PLAN9=/usr/local/plan9
+export PLAN9=/Users/rsc/plan9
export PATH=$PLAN9/bin:$PATH
case $# in
diff --git a/bin/doctype b/bin/doctype
index 3d720b8d..aaad8850 100755
--- a/bin/doctype
+++ b/bin/doctype
@@ -1,4 +1,4 @@
-#!/usr/bin/env $PLAN9/bin/rc
+#!/usr/bin/env rc
# doctype: synthesize proper command line for troff
troff=troff
diff --git a/bin/man b/bin/man
new file mode 100755
index 00000000..6a5f4db6
--- /dev/null
+++ b/bin/man
@@ -0,0 +1,120 @@
+#!/usr/bin/env rc
+
+. $PLAN9/man/fonts
+
+cmd=n
+sec=()
+S=$PLAN9/man
+d=0
+
+fn roff {
+ preproc=()
+ x=`{doctype $2}
+ if (~ $1 t) {
+ if(~ $x *grap*)
+ preproc=($preproc grap)
+ if(~ $x *pic*)
+ preproc=($preproc pic)
+ Nflag=-Tutf
+ }
+ if not {
+ Nflag=-N
+ }
+ if(~ $x *eqn*)
+ preproc=($preproc eqn)
+ if(~ $x *tbl*)
+ preproc=($preproc tbl)
+ switch($#preproc) {
+ case 0
+ {echo -n $FONTS; cat $2< /dev/null} | troff $Nflag -$MAN
+ case 1
+ {echo -n $FONTS; cat $2< /dev/null} | $preproc | troff $Nflag -$MAN
+ case 2
+ {echo -n $FONTS; cat $2< /dev/null} | $preproc(1) | $preproc(2) | troff $Nflag -$MAN
+ case 3
+ {echo -n $FONTS; cat $2< /dev/null} | $preproc(1) | $preproc(2) | $preproc(3) | | troff $Nflag -$MAN
+ case *
+ {echo -n $FONTS; cat $2< /dev/null} | $preproc(1) | $preproc(2) | $preproc(3) | | $preproc(4) | troff $Nflag -$MAN
+ }
+}
+
+fn page {
+ if(test -d /mnt/wsys/acme)
+ /bin/page -w
+ if not
+ /bin/page
+}
+
+
+while(~ $d 0) {
+ if(~ $#* 0) {
+ echo 'Usage: man [-ntp] [-s sec] [0-9] [0-9] ... name1 name2 ...' >[1=2]
+ exit
+ }
+ if(test -d $S/man$1){
+ sec=($sec $1)
+ shift
+ }
+ if not switch($1) {
+ case -t ; cmd=t ; shift
+ case -n ; cmd=n ; shift
+ case -p ; cmd=p ; shift
+ case -P ; cmd=P ; shift
+ case * ; d=1
+ }
+}
+if(~ $#sec 0) {
+ sec=`{ls -pd $S/man[0-9]* | sed 's/man//'}
+}
+ix=$S/man$sec/INDEX
+if(~ $#* 1) pat='^'^$1^' '
+if not pat='^('^`{echo $* | 9sed 's/ /|/g'}^') '
+fils=()
+for(i in $S/man$sec){
+ if(/bin/test -f $i/INDEX){
+ try=`{grep $pat $i/INDEX | 9sed 's/^[^ ]* //'}
+ if(! ~ $#try 0)
+ fils=($fils $i/$try)
+ }
+}
+# bug: should also do following loop if not all pages found
+if(~ $#fils 0) {
+ # nothing in INDEX. try for file of given name
+ for(i) {
+ for(n in $sec) {
+ try=$S/man$n/$i.$n*
+ if (/bin/test -f $try)
+ fils=($fils $try)
+ }
+ }
+ if(~ $#fils 0) {
+ echo 'man: no manual page' >[1=2]
+ exit 'no man'
+ }
+}
+for(i in $fils) {
+ if(! /bin/test -f $i)
+ echo need $i >[1=2]
+ if not {
+ switch($cmd) {
+ case t
+ roff t $i
+
+ case p
+ roff t $i | proof
+
+ case P
+ roff t $i |tr2post |psfonts >/tmp/man.$pid.ps
+ psv /tmp/man.$pid.ps
+ rm -f /tmp/man.$pid.ps
+
+ case n
+ roff n $i | 9sed '
+ ${
+ /^$/p
+ }
+ //N
+ /^\n$/D'
+ }
+ }
+}
diff --git a/bin/page b/bin/page
new file mode 100755
index 00000000..28997607
--- /dev/null
+++ b/bin/page
@@ -0,0 +1,53 @@
+#!/bin/sh
+
+preview()
+{
+ list=""
+ pwd=`pwd`
+ for i in "$@"
+ do
+ if [ -n "$list" ]
+ then
+ list="$list, "
+ fi
+ n=`cleanname -d $pwd $i | sed 's!/!:!g'`
+ list="$list\"$n\""
+ done
+ # echo run $list
+ echo 'tell application "Preview"
+ activate
+ open {'"$list"'}
+ end tell' | osascript
+}
+
+case $# in
+0)
+ cat >/var/tmp/page.$$.tmp
+ *="/var/tmp/page.$$.tmp"
+ ;;
+*)
+ ;;
+esac
+
+case `uname` in
+Darwin)
+ preview "$@"
+ ;;
+*)
+ case "`file $1`" in
+ *PDF*)
+ psv $1
+ ;;
+ *PS*)
+ psv $1
+ ;;
+ *PostScript*)
+ psv $1
+ ;;
+ *)
+ qiv "$@"
+ ;;
+ esac
+ ;;
+esac
+
diff --git a/bin/web b/bin/web
index 1745df50..0aafb76a 100755
--- a/bin/web
+++ b/bin/web
@@ -1,8 +1,58 @@
#!/bin/sh
-plumb1()
+plumbfirefox()
+{
+ echo '
+ tell application "Firefox"
+ activate
+ tell application "System Events"
+ tell process "firefox"
+ keystroke "t" using {command down}
+ end tell
+ end tell
+ Get URL "'$1'"
+ end tell
+ ' | osascript
+}
+
+plumbsafari()
+{
+ echo '
+ tell application "Safari"
+ activate
+ tell application "System Events"
+ tell process "safari"
+ keystroke "t" using {command down}
+ end tell
+ end tell
+ open location "'$1'"
+ end tell
+ ' | osascript
+}
+
+plumbapple()
{
- case x-$BROWSER in
+ case ${BROWSER:-none} in
+ firefox)
+ plumbfirefox "$@"
+ ;;
+ safari)
+ plumbsafari "$@"
+ ;;
+ none)
+ if [ -d /Applications/Firefox.app ]
+ then
+ plumbfirefox "$@"
+ else
+ plumbsafari "$@"
+ fi
+ ;;
+ esac
+}
+
+plumbunix()
+{
+ case ${BROWSER:-firefox} in
# Other browsers here
# ...
*opera*)
@@ -15,8 +65,8 @@ plumb1()
$BROWSER -remote 'openURL('$i',new-tab)'
;;
x-)
- # run firefox as default!
- firefox -remote 'openURL('$i',new-tab)'
+ BROWSER=firefox
+ $BROWSER -remote 'openURL('$i',new-tab)'
;;
*mozilla*)
$BROWSER -remote 'openURL('$i',new-tab)'
@@ -27,6 +77,19 @@ plumb1()
esac
}
+plumb1()
+{
+ case `uname` in
+ Darwin)
+ plumbapple "$@"
+ ;;
+ *)
+ plumbunix "$@"
+ ;;
+ esac
+}
+
+
if [ $# = 0 ]
then
plumb1 about:blank