mksh/dot.mkshrc

42 lines
1.4 KiB
Plaintext

: ${EDITOR:=/bin/ed} ${TERM:=vt100} ${HOSTNAME:=$(ulimit -c 0;hostname -s 2>&-)}
[[ $HOSTNAME = @(localhost|*([ ])) ]] && HOSTNAME=$(ulimit -c 0;hostname 2>&-)
PS1='# '; [[ "$(ulimit -c 0; id -u 2>&-)" -eq 0 ]] || PS1='$ '
PS1='$(integer e=$?; ((e)) && print $e\|)${USER:=$(ulimit -c 0; id -un 2>&- || \
print nobody)}@${HOSTNAME:=nil}:$(local pfx=~ wd=${PWD:-$(builtin pwd)}
integer n=${COLUMNS:-80}/3; let n="n < 7 ? 7 : n"
[[ ${wd#$pfx} = $wd || $pfx = ?(/) ]] || wd=\~${wd#$pfx}
pfx=; while (( (${#pfx} + ${#wd}) > n )); do
if [[ $wd = */* ]]; then
pfx=.../
wd=${wd#*/}
else
pfx=...
wd=${wd#?????}
fi
done; print -r -- "$pfx$wd") '$PS1
export EDITOR HOSTNAME MKSH=$(whence -p mksh) PS1 TERM USER
alias l='/bin/ls -F'
alias la='l -a'
alias ll='l -l'
alias lo='la -lo'
alias which='whence -p'
whence -p rot13 >&- || alias rot13='tr [A-Za-z] [N-ZA-Mn-za-m]'
whence -p hd >&- || function hd {
hexdump -e '"%08.8_ax " 8/1 "%02X " " - " 8/1 "%02X "' \
-e '" |" "%_p"' -e '"|\n"' "$@"
}
# strip comments (and leading/trailing whitespace if IFS is set) from
# any file(s) given as argument, or stdin if none, and spew to stdout
function Lstripcom {
cat "$@" | { set -o noglob; while read _line; do
_line=${_line%%#*}
[[ -n $_line ]] && print -r -- $_line
done; }
}
# place customisations between this line and the “: RCSID” line below
: $MirOS: src/bin/mksh/dot.mkshrc,v 1.15 2007/05/25 13:51:42 tg Rel $