ref: 78121c49f76ce415ded466f394aafd04901d2b27
dir: /fn/
# audio # playback samples from microphone (needs setup) fn admp{ dd -bs 4x441 </dev/audio >/dev/audio } # decode audio files(s) and visualize with pplay(1) fn pcm{ @{o=(); while(~ $1 -?) o=($o $1) && shift; play -o /fd/1 $* >[2]/dev/null | pplay $o}} # same, without temporary viariables (???) fn ppcm{ *=($*($#*) $* $#*) play -o /fd/1 $1 >[2]/dev/null | pplay $*(2-$*($#*)) } # convert a wolf3d digital audio lump fn wpcm{ audio/pcmconv -i u8c1r7000 -o s16c2r44100 <$1 >/dev/audio } # play(1) auxiliaries # skip to next track fn fw{ for(i in `{fpl}) echo 'echo kill >/proc/'^$i^/note } # pause playback fn sto{ for(i in `{fpl}) echo 'echo stop >/proc/'^$i^/ctl } # resume playback fn sta{ for(i in `{fpl}) echo 'echo start >/proc/'^$i^/ctl } # shortcuts for first play(1) process fn Fw{ fw | tail -1 | rc } fn Sta{ sta | tail -1 | rc } fn Sto{ sto | tail -1 | rc } # recursively list all files in arguments and play shuffled list forever fn shp{ *=`"{walk -f $*}; while(! ~ $#* 0) play `' '{echo -n $* | shl} |[2] sed -u '/^COVERART/d'} # shuffle play pre-arranged list of files forever fn shpp{ status='' while(~ $status '') play `{shl <$1} } # graphics # display wolf3d graphic lump using wpic and extracted picheader file fn wp{ a=(`{dd </n/tapefs/piched000.^$2 >[2]/dev/null -bs 4 -count 1 -skip $1 | xd -s -2d | sed 's/ 0+/ /g'}) wpic -x $a(2) -y $a(3) $*(3-) /n/tapefs/pic^$1^.$2 | page a=() } # programming # dump assembly fn asm{ 6c -FTVwSo /dev/null $1 } # ridiculous shortcut for one-file program builds fn b{ mk -f <{echo ' </$objtype/mkfile OFILES='$1'.$O </sys/src/cmd/mkone'} } # dump c function body (thanks aiju) fn catfn{ sed -n '/^'$1'\(/ {x;p;x;};/^'$1'\(/,/^}/p;h' *.c } # # file processing # recursive chown implementation, given fs access fn chown{ for(i in `' '{walk $*(2-)}){ chgrp $1 $i && chgrp -o $1 $i } } # lower filenames fn lw{ for(i in $*) mv $i `' '{echo $i | tr A-Z a-z} } # printing # show troff document fn doc{ troff -ms <$1 | page } # show ps document fn doc2{ echo `{doctype $1} '| lp -dstdout | page' | rc } # shortcuts # connect to aijuboard fn aib{ echo b115200 >/dev/eiaU*.1ctl && con -r /dev/eiaU*.1 } # ircs usage fn ii{ ircx -t '#cat-v' } # quake2 crbot fn q2cr{ qk2 -g crbot $* +set deathmatch 1 +set ctf 0 } # quake2 ctf fn q2f{ qk2 -g ctf $* +set ctf 1 } # launch graphical program on a unix host fn ff{ A=$*(2-); ssh $user@$1 'DISPLAY=:0 '^$"A^' >/dev/null 2>&1'; A=() } # defunct linux script shortcut #fn lnx{ linux -r $home/mroot /bin/bash -i } # vdir(1) fn ‡{ vdir $* } # rio # clear window fn clr{ {}>/dev/text } # get current window dimensions fn wsz{ dd -bs 4x12 -count 1 </mnt/wsys/wctl >[2]/dev/null | awk '{print $3-$1, $4-$2}' } # sys # bind hg repo to root and execute hg command fn hg{ bind -ac /dist/plan9front /; fn hg; hg $* } fn git{ bind -ac /dist/plan9front / } # hangup connections to given hosts fn nctl{ echo 'echo hangup >/net/'^`{netstat -n|sed -n 's,^([^ ]+) +([^ ]+) +[^ ]+ +[^ ]+ +[^ ]+ +'$1'.*,\1/\2/ctl\;,p'} } # show announced ports and established connections fn netopn{ netstat -n | grep 'Established|Listen' } # get list of /proc dirs for matched process names fn pn{ ps -n | sed -n '/.* '$1'$/s,[^ ]+ +([0-9]+).*,/proc/\1/,p' } # grep process table fn psd{ *=`{echo $"* | sed 's/ /|/g'}; ps -n | grep $* } # reset vga(8) state with vesa fn vr{ @{rfork n; aux/realemu; aux/vga -lm vesa $vgasize} } # mail # attempt at quoting fn qt{ cat | sed 's/^/> /' } # webshit # simple ninetimes fn 9t{ hget http://code.9front.org/hg/plan9front | htmlfmt | sed '1,6d;$d;/^[A-Za-z,]+ [0-9][0-9] [A-Za-z]+ 20[0-9][0-9] [0-9:]+ [0-9\+\-]+/{N;s/\n/ /;}' } # query english vocabulary fn geq{ plumb http://www.dictionary.com/browse/^$1 } # query german vocabulary fn gq{ plumb 'http://www.dict.cc/?s='^$* } # query weather fn wth{ plumb http://wttr.in/$1 } # trials from projects #fn ss{ sawk '{x[NR]=$4} END{freq(x); for(i in ans) print i, ans[i] | "sort -n"}' db0 } #fn wp{ # a=(`{dd </n/tapefs/piched000.^$2 >[2]/dev/null -bs 4 -count 1 -skip $1 | xd -s -2d | sed 's/ 0+/ /g'}) # wpic -x $a(2) -y $a(3) $*(3-) /n/tapefs/pic^$1^.$2 | page # a=() #} #fn shirc{ aux/listen1 -vp 1 tcp!*!17066 /bin/exportfs -R -r $home/lib -P <{echo '+ ^/k?irc$'} } #fn itest{ @{cd p/igfx/igdump; aux/vga -Vipm auto -l $vgasize >$home/v/vga >[2=1]; dumpsnb.rc | prettysnb.rc >>/tmp/snbv} } #fn idump{ @{cd p/igfx/igdump; dumpsnb.rc | prettysnb.rc > $home/vgam} } #fn gd{ *=`{echo $"* | sed 's/ /|/g'}; @{cd $home/p/not/ger; grep -i $* *} } #fn gq2{ # {for(i in $*) hget 'http://dict.tu-chemnitz.de/dings.cgi?query='^$i} | # sed -n 's/^.*onclick="return vi\(''([^)]+),[^,]+,''de'',''en'',this\).*/\1/p' | # sed 's/''//g;s/,/ → /' #} #fn ftp11{ ftpfs -/na anonymous@anonymous -o UNIX u11 } #fn ctopdf{ ps2pdf <{lp -dstdout -l100 -x0 -y0 -fCW.7 <{cat $*}} /fd/1 | pump } fn chi{ cd $home/p/sm2/cin && truetypefs && plumber && font=/n/ttf/unifont.ttf.16/font rio; unmount /mnt/plumb } fn chidiff{ diff <{ls *.pdf | sort} <{awk '{print $5}' db0 | sort} | sed -n '/^[0-9]/d;s/< /2.5 0 0 0 /p' }