ref: 2b61ac07407f664888705b5584b0ff04afb1dcda
parent: 25f9e2963d99c77c9c6c259820474c89076e0921
author: kvik <kvik@a-b.xyz>
date: Sun Jan 19 20:31:35 EST 2020
add ws(1)
--- /dev/null
+++ b/bin/ws
@@ -1,0 +1,45 @@
+#!/bin/rc -e
+# ws -- new workspace
+rfork en
+fn usage {>[1=2] echo 'usage:' $usage && exit 'usage'}
+usage='local [-r] mntcmd'
+
+fn mkname {
+ awk '
+ NR>72 {nm[i++] = $2}
+ END {srand(); print nm[int(rand()*length(nm))]}
+ ' /lib/volcanoes
+}
+
+restore='no'
+while(~ $1 -* && ! ~ $1 --){
+ switch($1){
+ case -r
+ restore='yes'
+ case *
+ usage
+ }
+ shift
+}
+if(~ $1 --)
+ shift
+
+name=$1
+if(~ $#name 0)
+ name=`{mkname}
+ws=$home/lib/ws/$name
+mkdir -p $ws
+echo $name >$ws/name
+
+if(~ $restore 'yes' && test -f $ws/mounts)
+ . $ws/mounts
+
+plumber
+w height .99 width 1 down
+bind /mnt/wsys /mnt/orio # w(1) hack
+cat >/env/run <<.
+#!/bin/rc
+label $name
+window 'w width height 1 Right; rc'
+.
+exec rio -i /env/run