shithub: rc

ref: 46f496eb000ddaef9961cccf50eeea55ab25fd4e
dir: /bin/kx/

View raw version
#!/bin/rc -b
rfork ne
pref=/n/ssh
wdir=$pref/strpg
usr=$user
fn usage{
	echo $0 >[1=2]
	exit usage
}
while(~ $1 -?){
	switch($1){
	case -d
		pref=/mnt/term/home/$user
		wdir=$pref/strpg
		shift
	case -r
		wdir=/n/ssh/$2
		shift
	case -u
		usr=$2
		shift
	case *
		usage
	}
	shift
}
if(~ $#* 1){
	m=$1
	if(! ~ $1 tcp!*)
		m=tcp!$1!x
}
if not if(! ~ $pref /mnt/term/*)
	usage
. /tmp/sizes.$sysname

f=()
cat <<'!' >/tmp/work.$pid
#!/bin/rc
label kx.$pid
if(test -f $home/lib/kx){
	f=`{cat $home/lib/kx}
	eval 'f=('^$"f^')'
}
. /tmp/sizes.$sysname

if(test $screensize(1) -le 1920)
	window -r $bsamrect 'echo -n /lib/font/bit/terminus/unicode.12m.font >/env/font; echo 4 >/env/tabstop; jam '^$"f
if not
	window -r $bsamrect 'echo 4 >/env/tabstop; jam '^$"f
!

cat <<! >/tmp/kx.$pid
#!/bin/rc
if(~ $wdir /n/ssh/*)
	sshfs $usr@$m || exit
cd $wdir || {echo root directory $wdir does not exist >[1=2]; sleep 10; exit usage}
unmount /mnt/plumb
plumbsrv=()
plumber -s plumb.$pid
bof -i /tmp/work.$pid
unmount -q /n/ssh
unmount /mnt/plumb
rm -f /srv/plumb.$pid /tmp/kx.$pid /tmp/work.$pid
!

chmod +x /tmp/work.$pid
chmod +x /tmp/kx.$pid
window -r $briorect /tmp/kx.$pid