mksh/dot.mkshrc
tg 8a59ee0311 * mention additions go at the bottom (e.g. 'source' scripts), in case
they fail (due to nonexistence), so that the rest is still executed
* export $MKSH (users can set SHELL=$MKSH here, but I'm conservative)
2007-01-04 23:40:50 +00:00

41 lines
1.3 KiB
Plaintext

# $MirOS: src/bin/mksh/dot.mkshrc,v 1.4 2007/01/04 23:40:50 tg Exp $
#-
# Add user-defined additions at the end, to prevent abortion on failure.
: ${EDITOR:=/bin/ed} ${HOSTNAME:=$(hostname -s 2>/dev/null || hostname)}
PS1='$(((rv=$?)) && print $rv\|)${USER:=$(id -un)}@${HOSTNAME:=nil}:$(
local pfx=~ wd=${PWD:-$(pwd)}
[[ ${wd#$pfx} = $wd || $pfx = ?(/) ]] || wd=\~${wd#$pfx}
pfx=; let n="( (n = ${COLUMNS:-80} / 3) < 7 ? 7 : n)"
while (( (${#pfx} + ${#wd}) > n )); do
if [[ $wd = */* ]]; then
pfx=.../
wd="${wd#*/}"
else
pfx=...
wd="${wd#?????}"
fi
done
print -r -- "$pfx$wd")'" $(if (( $(id -u) )); then
print \$; else print \#; fi) " MKSH=$(whence -p mksh)
export EDITOR HOSTNAME MKSH PS1 USER
alias l='/bin/ls -F'
alias la='l -a'
alias ll='l -l'
alias lo='la -lo'
[ -x /usr/bin/hd ] || eval alias 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 "$@" | while read _line; do
set -o noglob
_line=${_line%%#*}
[[ -n $_line ]] && print -r -- $_line
done
}