shithub: rcmisc

ref: 468e61644c1d6c846d737b5eb8f370f8938c0ec0
dir: /profile/

View raw version
#!/bin/rc

# env, -b so my things come first. allows for wrapper scripts
bind -b $home/bin/rc /bin
bind -b $home/bin/$cputype /bin
bind -a /bin/ndb /bin
bind -a /bin/ip /bin

GOROOT=/sys/lib/go/amd64-1.23.3/

# services
webfs
plumber

rm -rf /tmp/* 
ramfs -u

fn sam {
    /bin/sam -ai $*
}

fn rip {
    ip/ipconfig
    cat /net/ndb
}

fn ndb {
    cat /net/ndb
}

prevdir=/usr/$user
fn cd {
    if(~ $(1) '-') { cd $prevdir }
	if not { 
	   if(! ~ $prevdir $*) prevdir=`{pwd}
	   builtin cd $*
	}
}

fn reacme {
    acme -l $home/acme.dump
}

fn e {
    sam $*
}

fn eprof {
    acme $home/lib/profile
}

fn eterm {
    acme $home/bin/rc/termstart
}

fn ecpu {
    acme $home/bin/rc/cpustart
}

fn endb {
    acme /lib/ndb/local
}

fn ld {
    ls -F $* | grep / | mc
}

fn env {
    for(var in /env/*){
        echo $var '=' `{cat $var}
    }
}

fn bins{ 
    ls -F /bin* | grep $*
}

fn todo {
    e $home/TODO
}

fn lextras {
    9fs 9front
    bind /n/9front /extras
}

font=/lib/font/bit/gomono/Go-Mono.14.font

switch($service){
case terminal
	echo -n accelerated > '#m/mousectl'
	echo -n 'res 3' > '#m/mousectl'
	9fs esp
	bind /n/esp esp
	lola -i termstart -s
case cpu
	bind /mnt/term/dev/cons /dev/cons
	bind -q /mnt/term/dev/consctl /dev/consctl
	>[2] /dev/null {
		cp /dev/sysname /mnt/term/dev/label
		if(test -s /mnt/term/env/wsys)
			wsys=/mnt/term^`{cat /mnt/term/env/wsys}
	} 
	bind -a /mnt/term/dev /dev
	
	# Set custom options based off crude OS fingerprinting
	if(ls /mnt/term | grep -s Volumes){
	   # macos: retina display means we need a bigger font
	   font=/lib/font/bit/lucidasans/typeunicode.16.font
	}
    if not if(ls /mnt/term | grep -s C:){
        # Windows
    }
	if not{
	   # *nix: we probably have fuse to mount 9's fs on the client
	   $home/bin/rc/p9fs
	}
	
	lola -i cpustart -s
case con
	prompt=('con% ' '	')
}