ref: 307708d55f9de510055ba4024ddaecd97a938001
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 | sed 1q | rc } fn Sta{ sta | sed 1q | rc } fn Sto{ sto | sed 1q | rc } # recursively list all files in arguments and play shuffled list forever fn shp{ *=`"{lr -Q $*}; while(! ~ $#* 0) play `' ' {echo -n $* | shl} } # 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 `' '{lr -Qd $*(2-)}){ chgrp $1 $i && chgrp -o $1 $i } } # silly recursive grep(1) fn gr{ lr -Q $*(2-) | xargs grep -n $1 } # 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 } # wircrc usage fn ii{ wircrc -T -p 6697 -c 'irc.freenode.net!#cat-v,irc.freenode.net!#setecastronomy' -n qwx } # quake2 crbot fn q2cr{ qk2 -g crbot $* +set deathmatch 1 +set ctf 0 } # quake2 ctf fn q2f{ qk2 -g ctf $* +set ctf 1 } # display shuffled list of images fn shi{ page `' '{lr -Q $* | shl | sed 5000q} } # default vt(1) params fn t{ vt -2bf /lib/font/bit/fixed/unicode.6x10.font } # launch graphical program on a unix host fn ff{ A=$*(2-); ssh $user@$1 'DISPLAY=:0 '^$"A^' >/dev/null 2>&1'; A=() } # 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 fhg{ bind -ac /dist/plan9front /; fn fhg; hg $* } # 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 # manual mail archive fn arc{ cat >/mail/box/qwx/arc/`{date -n} } # update dir with new messages from archived mailing list fn mlu{ cd /n/lists.9front.org/lists/$1; tar c `{diff <{lr} <{cd $2; lr} | sed '/^[^<]/d;s/< //'} | @{cd $2; tar xT} } # 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 }