# attila's plain old ksh .kshrc for OpenBSD (Updated: 2022-02-03) # Also works with loksh under void linux w/my .profile (2021-12-07) ## Environment # bsd polyfill v2.0 local uuu=$(uname) case $uuu in Linux) stty_size_field () { stty -a | perl -lne '/'$1'\s+(\d+);/ && print $1' } linux () { eval "$@" } bsd () { # nothing } _poly_colorer=_color_ _poly_setaf=setf _poly_setab=setb ;; *BSD) stty_size_field () { stty -a | perl -lne '/(\d+)\s+'$1'/ && print $1' } linux () { # nothing } bsd () { eval "$@" } _poly_colorer=_color_a _poly_setaf=setaf _poly_setab=setab ;; *) linux () { echo "# $uuu? $@" eval $@ } bsd () { echo "# $uuu? $@" eval $@ } ;; esac # N.B. we source ~/.kshrc_local at the end if it exists, to provide # a way to override these settings on specific machines export LANG=en_US.UTF-8 export PATH=$HOME/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/X11R6/bin:/usr/local/bin:/usr/local/sbin bsd PATH=${PATH}:/usr/ports/infrastructure/bin:/usr/games bsd export MANPATH=/usr/share/man:/usr/X11R6/man:/usr/local/man:/usr/ports/infrastructure/man bsd export CVSROOT=anoncvs@anoncvs4.usa.openbsd.org:/cvs bsd 'export ARCH=$(arch -s)' bsd 'export NCPUS=$(sysctl -n hw.ncpu)' export NODENAME=$(hostname | awk -F. '{print $1}') export PS1='\u@\h:\W \!\$ ' # c.f. adapt_prompt(), below #export MAX_PROMPT_PERCENT=25 # ditto #export MY_OWNER=attila # don't set this here mv it to .kshrc_local XXX ## General Unix Stuff # keep certain destructive commands from being run in $HOME w/o # confirmation homecheck () { if [ $# -eq 0 -o x$1 != 'x-h' ]; then if [ $(pwd) = $HOME ]; then echo 'sure about that? pwd is $HOME; -h to override'>&2 echo no else echo ok fi else echo ok fi } # all garbage files in the current dir alias filth='find . -maxdepth 1 -type f -a \( -name '\''*~'\'' -o -name '\''\#*\#'\'' -o -name '\''*.BAK'\'' -o -name '\''*.OLD'\'' -o -name '\''.*~'\'' -o -name '\''.*.BAK'\'' -o -name '\''.*.OLD'\'' -o -name core -o -name '\''*.core'\'' \)' # all garbage files in the current directory tree alias dfilth='find . -type f -a \( -name '\''*~'\'' -o -name '\''\#*\#'\'' -o -name '\''*.BAK'\'' -o -name '\''*.OLD'\'' -o -name '\''.*~'\'' -o -name '\''.*.BAK'\'' -o -name '\''.*.OLD'\'' -o -name core -o -name '\''*.core'\'' \)' # clean all the garbage in the current dir alias clean='filth -print -exec rm {} \;' # clean all the garbage in the current tree, but carefully dclean () { if [ $(homecheck $*) = ok ]; then dfilth -print -exec rm {} \; fi } # basic shit in my ~/.profile since 1979 or somethin alias cx="chmod +x" alias l="ls -sFC" alias ll="ls -l" alias lsd="ls -d" alias lart="ls -lart" alias s0rt="sort -n" alias hogs="du -sk * | s0rt" bighogs () { local nbig nbig=$1 [ -z $nbig ] && nbig=10 du -sk * | sort -n | tail -$nbig } alias m=more alias e=echo unalias d d () { echo "[#] $*" 1>&2 } alias uc='tr a-z A-Z' alias ztvf="tar ztvf" alias zxvf="tar zxvf" alias tvf="tar tvf" alias xvf="tar xvf" alias srm='rm -P' alias tl='tail -40' alias trail='tail -100f' alias dmt='dmesg|tl' alias ronidate='date +"%m.%d.%y"' # how my wife does it alias now="date +'%a %d-%b-%Y %T %Z' | uc" alias isodate="date +'%Y-%m-%dT%H:%M:%S%z'" # strip comments and blank lines out of most config files #alias bareconf="sed -e '/^[ \t]*[#;]/d' -e '/^[ \t]*$/d'" alias bareconf="perl -lne 'print unless /^\s*[#;]/ || /^\s*$/'" # random password alias passwrd='jot -r -c -s "" 12 / {' # pingy stuff alias p5='ping -c 5' alias p10='ping -c 10' bsd alias _grep_def="grep\ ^default" bsd alias _netstat_nr="netstat\ -nr\ -f\ inet" bsd alias nsa4="netstat\ -na\ -f\ inet" linux alias _grep_def="grep\ ^0.0.0.0" linux alias _netstat_nr="netstat\ -nr4" linux alias nsa4="netstat\ -na4" alias gwip='_netstat_nr | _grep_def | head -1 | awk "{print \$2}"' alias gwif='_netstat_nr | _grep_def | head -1 | awk "{print \$NF}"' alias pingw='ping $(gwip)' alias p5gw='ping -c 5 $(gwip)' # yes, linux has damaged my brain bsd alias sudo=doas linux alias doas=sudo alias n=numbers alias s='numbers -S' alias rep='. ~/.kshrc' # common xclip invocations to go between tmux and X session alias clipboard='echo $(xclip -o)' alias setclip='xclip -selection primary -i' alias clipmux='tmux set-buffer "$(clipboard)"; clipboard' alias clipmuxq='tmux set-buffer "$(clipboard)"' alias muxclip='tmux show-buffer | tee /dev/stderr | setclip' alias muxclipq='tmux show-buffer | setclip' alias muxhub0='tmux show-buffer | ssh hub0 share-tmux-paste' ##+ttys _color_a () { # N.B. this is for seta[fb] c.f. terminfo(5) local c n=$(echo $1 | tr A-Z a-z) case $n in black) c=0 ;; red) c=1 ;; green) c=2 ;; yellow) c=3 ;; blue) c=4 ;; magenta)c=5 ;; cyan) c=6 ;; white) c=7 ;; *) die "wtf color is $1 ?" ;; esac echo $c } _color_ () { # N.B. this is for set[fb] c.f. terminfo(5) local c n=$(echo $1 | tr A-Z a-z) case $n in black) c=0 ;; blue) c=1 ;; green) c=2 ;; cyan) c=3 ;; red) c=4 ;; magenta)c=5 ;; yellow) c=6 ;; white) c=7 ;; *) die "wtf color is $1 ?" ;; esac echo $c } set_fg () { local color=$1 term=$2 [ -z "$term" ] && term=xterm env TERM=$term tput $_poly_setaf $($_poly_colorer $color) } set_bg () { local color=$1 term=$2 [ -z "$term" ] && term=xterm env TERM=$term tput $_poly_setab $($_poly_colorer $color) } tty_rows () { echo $(stty_size_field rows) } tty_cols () { echo $(stty_size_field columns) } center_msg () { my x y str mid_len str="$*" mid_len=${#str} mid_len=$(expr $mid_len / 2) x=$(tty_cols) y=$(tty_rows) y=$(expr $y / 2) y=$(expr $y - 1) x=$(expr $x / 2) x=$(expr $x - $mid_len) tput clear tput cup $y $x tput bold echo -n $str tput sgr0 tput civis 2>/dev/null } ##-ttys ##+tmux # tmux fu # current window name w/o my [brackets] alias curwin="tmux display-message -p '#W' | sed -e 's/^\[//' -e 's/\]$//'" # resetlay [windowname] - reset the layout in (current) tmux window resetlay () { local win script cmd if [ -$# -gt 0 ]; then win=$1 shift else win=$(curwin) fi script=$HOME/tmp/setup-${win}-win.sh if [ ! -f ${script} ]; then echo "no script: $script" return 1 fi grep '^tmux select-layout' $script | tee /dev/stderr | sh } # save current window layout in window init script savelay () { local win lay script if [ -$# -gt 0 ]; then win=$1 shift else win=$(curwin) fi script=$HOME/tmp/setup-${win}-win.sh lay=$(tmux list-windows|fgrep "[${win}]"|perl -lpe 's/^.*\[layout\s//; s/\]\].*$//') echo "# ${win} current layout: ${lay}" if [ ! -f ${script} ]; then echo '# created by savelay' > ${script} fi perl -lpe 's/^tmux select-layout/#tmux select-layout/' < $script > ${script}.new echo "tmux select-layout -t '[${win}]' '${lay}'" >> ${script}.new mv ${script} ${script}.bak mv ${script}.new ${script} echo "# wrote ${script}" } ##-tmux ##+ssh # SSH fu, mainly to do with creds # ssh agent mgmt: display, save and load agent rendezvous envars # useful for mosh'ing through some bouncepoint, since mosh can't forward auth alias agentenv="perl -e 'foreach (grep { /^SSH_/ } sort keys %ENV) { print qq|\$_=\"\$ENV{\$_}\"\nexport \$_\n|; }'" alias saveagent='agentenv | tee $HOME/.ssh/agent_info' alias reagent='. $HOME/.ssh/agent_info && ssh-add -l' alias initagent='eval $(ssh-agent -s); saveagent' ##-ssh ##+psmap # Killing processes # psmap is a perl script i wrote 20y ago to map a unix command over # matching processes; can't quite get used to pkill, sorry... alias psg='psmap -vn' # kill processes that match psk () { psmap -v "$*" kill } # kill -9 procs that match psk9 () { psmap -v "$*" kill -9 } # kill procs as root (sudo kill) spsk () { psmap -v "$*" doas kill } # kill -9 procs as root spsk9 () { psmap -v "$*" doas kill -9 } ##-psmap ##+openbsd # OpenBSD fu, mainly to do with ports and working on the kernel alias sqlports='sqlite3 /usr/local/share/sqlports' # log my cvs updates so I can figure out what happened alias cvsup='(echo -n "### $CVSROOT $(basename `pwd`) "; now; cvs -d$CVSROOT up -Pd) | tee -a $HOME/logs/$(basename `pwd`).update.log' ### ... snapshots OUR_MIRROR=cdn.openbsd.org # grab latest snapshot into ., optional arg = arch (default = current arch) # can also grab non-snapshot by specifying version as second arg ftpsnap () { local arch vers arch=$(arch -s) vers=snapshots [ -n $1 ] && arch=$1 [ -n $2 ] && vers=$2 ftp -Cav ftp://${OUR_MIRROR}/pub/OpenBSD/${vers}/${arch}/'{BOOT*,BUILDINFO,INSTALL*,SHA*,index.txt,bsd,bsd.{rd,mp},*.tgz}' } # print the BUILDINFO from the latest snap on stdout snapdate () { local arch arch=$(arch -s) [ $# -gt 0 ] && arch=$1 ftp -MVa -o - ftp://${OUR_MIRROR}/pub/OpenBSD/snapshots/${arch}/BUILDINFO } #alias verisnap='signify -C -p /etc/signify/openbsd-``-base.pub -x SHA256.sig bsd* *.tgz' unalias verisnap # verify the snapshot in ., optionsal arg is version for key verisnap () { local vers vers=$(uname -r) [ $# -gt 0 ] && vers=$1 vers=$(echo ${vers} | sed -e "s/\.//") echo signify -C -p /etc/signify/openbsd-${vers}-base.pub -x SHA256.sig bsd* *.tgz signify -C -p /etc/signify/openbsd-${vers}-base.pub -x SHA256.sig bsd* *.tgz } # grab the latest snap and verify it # $ getsnap [vers [arch]] getsnap () { local arch vers arch=$(arch -s) vers=$(uname -r | sed -e "s/\.//") [ $# -gt 0 ] && { vers=$1 shift } [ $# -gt 0 ] && { arch=$1 shift } echo "[arch: $arch, vers: $vers]" ftpsnap ${arch} verisnap ${vers} } # tell us how long the current snap has been out with some ub magic snapout () { snapdate | \ ub -Q '$_ = ; $_ =~ /^.*: (\d+) -.*$/ && $_ . elapsed_string time - $1' } ##-openbsd ## Proxy fu alias prox='echo "[Proxies: http: $http_proxy, https: $https_proxy]"' alias nyprox='export http_proxy=http://10.20.30.1:8987; export https_proxy=https://10.20.30.1:8987; prox' alias noprox='unset http_proxy; unset https_proxy; prox' ##+ttyplot # ping rtt plot pingplot () { local errfile="/tmp/$1.errs" ping $* 2>$errfile | sed -u "s/^.*time=//g; s/ ms//g" | \ ttyplot -u ms -t "ping rtt: $*" } # ping rtt plot, alt approach pingplot2 () { local host=$1 errfile="/tmp/$1.errs" shift local null=0 [ $# -gt 0 ] && { null=$1 shift } local opts="$*" while true; do local val=$(ping -c 1 -w 5 $opts $host 2>$errfile | grep time= | sed -u "s/^.*time=//g; s/ ms//g") [ -z "$val" ] && { val=$null } echo $val done | ttyplot -u ms -t "ping rtt: $host" } # interface rate in/out composite plot ifaceplot () { local iface [ $# -gt 0 ] && { iface=$1 shift } [ -z "${iface}" ] && iface=$(gwif) while true; do systat -B -s 0.1 if | grep ^${iface} | perl -lane 'BEGIN {$|=1} print $F[3]/1024.0," ",$F[6]/1024.0' sleep 1 done | ttyplot -2 -r -u kB/s -t "${iface} I/O" } # map column# in vmstat output -> symbolic name vmcolnm () { local x=$1 case $1 in 0) x=runnable ;; 1) x=sleeping ;; 2) x=active ;; 3) x=free ;; 4) x=pagefaults ;; 5) x=reclaims ;; 6) x=pagein ;; 7) x=pageout ;; 8) x=pagefree ;; 9) x=scanned ;; 10) x=sd0 ;; 11) x=cd0 ;; 12) x=interrupts ;; 13) x=syscalls ;; 14) x=switches ;; 15) x=user ;; 16) x=system ;; 17) x=idle ;; esac echo $x } # map symbolic name -> column in vmstat output vmnmcol () { local x=$1 case $1 in act*) x=2 ;; cd0|disk1) x=11 ;; free*) x=3 ;; id*) x=17 ;; int*) x=12 ;; run*) x=0 ;; pagefa*) x=4 ;; pagei*) x=6 ;; pageo*) x=7 ;; pagefr*) x=8 ;; re*) x=5 ;; sc*) x=9 ;; sd0|disk0) x=10 ;; sl*) x=1 ;; sw*) x=14 ;; sysc*) x=13 ;; syst*) x=16 ;; us*) x=15 ;; esac echo $x } # e.g. $ vmplot interrupts vmplot () { local col vcol if [ $# -gt 0 ]; then col=$1 shift else col=3 fi vcol=$(vmnmcol $col) vmstat 1 | \ perl -lane 'BEGIN {$|=1} $x=$F['$vcol']; $x=~s/M$//; print $x'|\ ttyplot -t "vmstat $col" } # e.g. $ vm2plot pagefaults free vm2plot () { local col0 col1 vcol0 vcol1 if [ $# -gt 0 ]; then col0=$1 shift if [ $# -gt 0 ]; then col1=$1 shift else col1=14 fi else col0=3 col1=14 fi vcol0=$(vmnmcol $col0) vcol1=$(vmnmcol $col1) vmstat 1 | \ perl -lane 'BEGIN {$|=1} ($x,$y)=($F['$vcol0'],$F['$vcol1']); $x=~s/M$//; $y=~s/M$//; print "$x $y"' | \ ttyplot -2 -t "vmstat $col0 vs. $col1" } # e.g. $ sysplot load sysplot () { local what=$1 unitz=$2 title=$3 [ -z "$what" ] && what=load [ -n "$unitz" ] && unitz="-u $unitz" [ -z "$title" ] && title="$what" while true; do ${what} sleep 1 done | ttyplot ${unitz} -t $title } # e.g. $ sysplot interrupts pagefaults sys2plot () { local what1=$1 what2=$2 while true; do echo "$(${what1}) $(${what2})" sleep 1 done | ttyplot -2 -t "$what1 vs $what2" } # e.g. $ sysctlplot nprocs sysctlplot () { local what=$1 case $what in kern.*) ;; *) what=kern.$what ;; esac while true; do sysctl -n $what sleep 1 done | ttyplot -t $what } ##-ttyplot ## Limits unlimit () { ulimit -f unlimited ulimit -d unlimited ulimit -s unlimited ulimit -m unlimited ulimit -l unlimited ulimit -u unlimited ulimit -n unlimited } delimit () { unlimit ulimit -a } ##+perl # Perl hacking # $ VERS JS::SourceMap # JS::SourceMap 0.1.1 VERS () { for m in $*; do perl -M$m -e 'no strict; $p=join("/",split("::","'$m'")).".pm";print qq{'$m'\t$'$m'::VERSION\t$INC{$p}\n};' done } # $ local::lib somedir # to use somedir # $ local::lib -d # undoes above # $ local::lib # shows current state local::lib () { if [ "$1" = "-d" ]; then if [ -z "$2" ]; then eval $(perl -Mlocal::lib=--deactivate-all) else eval $(perl -Mlocal::lib=--deactivate,$2) fi if [ -n "${unlocal_MANPATH}" ]; then export MANPATH=$unlocal_MANPATH export unlocal_MANPATH="" fi export PATH # d "PATH after -d: $PATH" adapt_prompt -u elif [ -n "$1" ]; then local _local lochome _local="$1" [ -z "$_local" ] && _local=$HOME/perl5 colon_MANPATH="" if [ -n "$MANPATH" ]; then export unlocal_MANPATH=$MANPATH export colon_MANPATH=:${MANPATH} fi lochome=`echo $_local | sed -e "s,^${HOME},~,"` # d "_local: $_local lochome: $lochome" # d "evaling: $(perl -Mlocal::lib=${_local})" eval "$(perl -Mlocal::lib=${_local})" export PATH="${_local}/bin:$PATH" # d "PATH after: $PATH" export MANPATH=${_local}/man${colon_MANPATH} adapt_prompt -p $lochome -S echo '[Pushed '$_local']' fi if [ -z "$PERL5LIB" ]; then echo 'Not using local::lib' else echo 'PERL5LIB: '$PERL5LIB'; use local::lib -d to ditch it' fi } ##-perl ##+python # Python hacking # $ activate foo # is nicer than $ . ~/virtual/foo/bin/activate activate () { vbase=${MY_VIRTUAL_ENVS-$HOME/virtual} nm="$1" if [ x"$nm" = x ]; then ls -l ${vbase} elif [ ! -d ${vbase}/${nm} ]; then echo 'What should I activate?' else . ${vbase}/${nm}/bin/activate echo '[Use the "deactivate" command to pop out of '$nm']' fi } ##-python ##+ports alias stem="perl -lpe 's/^([\w\d-]+)-\d.*\$/\$1/'" alias mdeps='while read pkg; do pkg_info -e $pkg || echo miss:$pkg; done' alias rdeps='make full-run-depends|mdeps' alias btdeps='make full-{build,test}-depends|sort -u|mdeps' alias missdeps='btdeps | grep ^miss:' alias missrdeps='rdeps | grep ^miss:' alias instmiss='doas pkg_add $(missdeps | sed -e "s/^miss://")' # use locate (1) to find ports locport () { locate $* | grep ^/usr/ports | awk -F/ '{print $4,$5}' | sort -u } # use make search under /usr/ports to search ports searchport () { (cd /usr/ports; make key="$*" search | grep ^Path:) } ## Stuff for work on ports, developed during Tor Browser days # Frequently you have a tree of stuff one place and a proposed new # version somewhere else and you need to bounce back and forth, # comparing diffs and such. These envars, functions and aliases are # what I came up with for my work flow, YMMV. # base working dir DIFFS_BASE=/usr/ports/mystuff/www/tbb # reference dir DIFFS_REF=$HOME/src/torbsd-ports-leap-6.0 export DIFFS_BASE DIFFS_REF # try to set DIFFS_BASE and DIFFS_REF based on pwd base () { if [ -n "$1" ]; then if [ -n "$2" ]; then DIFFS_BASE=$1 DIFFS_REF=$2 elif [ -d /usr/ports/mystuff/$1 ]; then DIFFS_BASE=/usr/ports/mystuff/$1 if [ -z "$2" ]; then DIFFS_REF=/usr/ports/$1 else DIFFS_REF=$2 fi elif [ $1 = /usr/src ]; then DIFFS_BASE=/usr/src DIFFS_REF=$HOME/src/openbsd-base elif [ $1 = switch ]; then local tmp=$DIFFS_BASE DIFFS_BASE=$DIFFS_REF DIFFS_REF=$tmp else echo 'do not understand base: '$1 fi export DIFFS_BASE DIFFS_REF fi echo 'base: '${DIFFS_BASE} echo 'ref: '${DIFFS_REF} } alias diffs='diff -Nupr -x CVS $DIFFS_BASE $DIFFS_REF' alias files='diffs | grep ^diff' # e.g.: $ filez # list differing filenames # $ filez ls -l | sh # ls -l both versions of all changed files # $ filez cp # see what would be copied... # $ filez cp | sh # ... and do it filez () { if [ -z "$1" ]; then files else # e.g.: $ filez ls -l | sh files | sed -e "s/^diff -Nupr -x CVS/$*/" fi } # i miss pushd/popd from zsh. this is good enough and in some ways better # you can use anything that make show= understands, e.g.: $ goto WRKSRC # helper goto_ () { _goto_prev=`pwd` _goto_dir=$1 if [ ! -d ${_goto_dir} ]; then case "$_goto_prev" in /usr/ports/*) _port=`basename $_goto_prev` _goto_dir=`make show=$1` if [ -z "${_goto_dir}" ]; then echo "[what is $1?]" else echo "[$1 of ${_port} is ${_goto_dir}]" fi ;; esac fi while [ ! -d ${_goto_dir} ]; do echo "${_goto_dir} not a dir - using `dirname ${_goto_dir}`" _goto_dir=`dirname ${_goto_dir}` done cd $_goto_dir } goto () { if [ -z "$1" ]; then if [ -n "$_goto_prev" ]; then goto_ ${_goto_prev} else echo goto: no previous directory fi else goto_ $1 fi echo `pwd` '('$_goto_prev')' } ##-ports ##+xwin # X Windows # x11 - start xwindows and send timestamped logs to a Unix-domain socket # the xlog command should be run inside of X to see the log spew # N.B. I start e.g. ssh-agent, etc by hand myself when I log in on console # Not a fan of this stuff being done automatically for me. Especially # not a fan of ~/.xsession-errors, an idea which needs to die. x11 () { if [ -n "${DISPLAY}" ]; then echo 'Looks like you are already in X: DISPLAY='$DISPLAY else rm -f $HOME/.xinit_sock echo -n 'Hit ^C when you drop out of X Windows...' xinit 2>&1 | ts -days | nc -lkU $HOME/.xinit_sock fi } # xlog - read from the Unix-domain socket created by x11, above alias xlog='nc -vU $HOME/.xinit_sock' ##-xwin # front end to screen_title.pl/xtitle depending set_title () { local tit tit="$*" [ -z "${tit}" ] && tit="ksh" case "$TERM" in xterm*) xalltitles "[${NODENAME}] ${LOGNAME}: ${tit}" ;; screen*) xalltitles "[${tit}]" ;; *) ;; esac } adapt_prompt () { local fancy=0 shorty=0 prefix="" stick=0 while [ $# -gt 0 ]; do case $1 in fancy|-f) fancy=1 ;; shorty|-s) shorty=1 ;; -p) shift; prefix="$1" ;; -S) stick=1 ;; # used by local::lib -u) unset _STICKY_PREFIX; unset _STICKY_FANCY; ;; -h) echo '-f fancy -s shorty -p prefix -S stick -u unstick' return 0;; esac shift done if [ -z "$prefix" ]; then prefix="${_STICKY_PREFIX}" fi if [ -n "${_STICKY_FANCY}" ]; then fancy=${_STICKY_FANCY} fi if [ $stick -ne 0 -a $fancy -ne -0 ]; then _STICKY_FANCY=1 fi if [ -n "$prefix" ]; then if [ $stick -ne 0 ]; then _STICKY_PREFIX="${prefix}" export _STICKY_PREFIX fi prefix="{$prefix} " fi if [ $shorty -ne 0 ]; then export PS1='\$ ' return fi local wide=$(tty_cols) u=$(whoami) ucolon uat wbracks if [ -n "$MY_OWNER" -a "$u" = "${MY_OWNER}" ]; then ucolon="" uat="" wbracks="[\\w]" else ucolon="${u}:" uat="${u}@" wbracks="\\w" fi if [ $wide -gt 70 -o $fancy -ne 0 ]; then local n="$(pwd)" if [ "$n" = "${HOME}" ]; then n='~' fi local len=${#n} local p=$(perl -e "print int(100*(${len}/$(tty_cols)))") local maxp=${MAX_PROMPT_PERCENT-30} if [ $p -gt $maxp -o $fancy -ne 0 ]; then local a0=$(print \\001) cr=$(print \\r) local cyan="${a0}$(set_fg cyan)${a0}" local green="${a0}$(set_fg green)${a0}" local red="${a0}$(set_fg red)${a0}" PS1="${a0}${cr}${cyan}[\\w]${green} ${prefix}\\n${uat}\\h <\\D{%H:%M}>${red}\\$ ${green}" else PS1="${prefix}${uat}"'\h <\\D{%H:%M}>\$ ' fi elif [ $wide -gt 50 ]; then PS1="${prefix}"'\h <\D{%H:%M}>\$ ' elif [ $wide -gt 45 ]; then if [ -z "$TMUX" ]; then PS1="${prefix}"'\h\$ ' else PS1="${prefix}"'\$ ' fi else PS1="${prefix}"'\$ ' fi export PS1 } alias ap=adapt_prompt [ -f ~/.kshrc_local ] && . ~/.kshrc_local [ -n "$MY_OWNER" ] && export PATH=/home/${MY_OWNER}/bin:${PATH} ##+nyet # dumb aliases that save my ass over a shit nyet alias gpto='git push origin trunk' alias gpot='git pull origin trunk' alias reag=reagent alias mup='make update-port' ##-nyet ## Interactive sessions: make sure ^T/^C set correctly, set title [ -t 0 ] && { bsd stty status ^T intr ^C linux stty intr ^C set_title set -o emacs adapt_prompt ${ADAPT_PROMPT_INIT} }