• whence -p can take closing fd 2 instead of pointing it to /dev/null
• hostname and id should too, besides it's mostly for the shell error message of not finding them anyway… • shorten
This commit is contained in:
parent
fcd6e4f07a
commit
9e21d616bd
28
dot.mkshrc
28
dot.mkshrc
|
@ -1,16 +1,11 @@
|
|||
: ${EDITOR:=/bin/ed} ${TERM:=vt100}
|
||||
[[ ${HOSTNAME:=$(ulimit -c 0; hostname -s 2>/dev/null)} = \
|
||||
@(localhost|*([ ])) ]] && HOSTNAME=$(ulimit -c 0; hostname 2>/dev/null)
|
||||
if [[ $(ulimit -c 0; id -u 2>/dev/null) -eq 0 ]]; then
|
||||
PS1='# '
|
||||
else
|
||||
PS1='$ '
|
||||
fi; PS1='$(integer rv=$?; ((rv)) && print -n $rv\|)${USER:=$(ulimit -c 0; \
|
||||
id -un 2>/dev/null || print -n nobody)}@${HOSTNAME:=nil}:$(
|
||||
local pfx=~ wd=${PWD:-$(builtin pwd)}; integer n=${COLUMNS:-80}/3
|
||||
: ${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=; let n="n < 7 ? 7 : n"
|
||||
while (( (${#pfx} + ${#wd}) > n )); do
|
||||
pfx=; while (( (${#pfx} + ${#wd}) > n )); do
|
||||
if [[ $wd = */* ]]; then
|
||||
pfx=.../
|
||||
wd=${wd#*/}
|
||||
|
@ -18,16 +13,15 @@ fi; PS1='$(integer rv=$?; ((rv)) && print -n $rv\|)${USER:=$(ulimit -c 0; \
|
|||
pfx=...
|
||||
wd=${wd#?????}
|
||||
fi
|
||||
done
|
||||
print -nr -- "$pfx$wd") '$PS1
|
||||
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'
|
||||
whence -p rot13 >/dev/null || alias rot13='tr [A-Za-z] [N-ZA-Mn-za-m]'
|
||||
whence -p hd >/dev/null || function hd {
|
||||
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"' "$@"
|
||||
}
|
||||
|
@ -43,4 +37,4 @@ function Lstripcom {
|
|||
|
||||
# place customisations between this line and the “: RCSID” line below
|
||||
|
||||
: $MirOS: src/bin/mksh/dot.mkshrc,v 1.12 2007/04/17 20:07:09 tg Rel $
|
||||
: $MirOS: src/bin/mksh/dot.mkshrc,v 1.13 2007/05/19 16:33:10 tg Exp $
|
||||
|
|
Loading…
Reference in New Issue