2007-04-16 20:54:37 +02:00
|
|
|
: ${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
|
2006-07-23 20:44:22 +02:00
|
|
|
[[ ${wd#$pfx} = $wd || $pfx = ?(/) ]] || wd=\~${wd#$pfx}
|
2007-04-16 20:54:37 +02:00
|
|
|
pfx=; let n="n < 7 ? 7 : n"
|
2006-07-23 20:44:22 +02:00
|
|
|
while (( (${#pfx} + ${#wd}) > n )); do
|
|
|
|
if [[ $wd = */* ]]; then
|
|
|
|
pfx=.../
|
2007-04-16 20:54:37 +02:00
|
|
|
wd=${wd#*/}
|
2006-07-23 20:44:22 +02:00
|
|
|
else
|
|
|
|
pfx=...
|
2007-04-16 20:54:37 +02:00
|
|
|
wd=${wd#?????}
|
2006-07-23 20:44:22 +02:00
|
|
|
fi
|
|
|
|
done
|
2007-04-16 20:54:37 +02:00
|
|
|
print -nr -- "$pfx$wd") '$PS1
|
|
|
|
export EDITOR HOSTNAME MKSH="$(whence -p mksh)" PS1 TERM USER
|
2006-07-23 20:44:22 +02:00
|
|
|
|
|
|
|
alias l='/bin/ls -F'
|
|
|
|
alias la='l -a'
|
|
|
|
alias ll='l -l'
|
|
|
|
alias lo='la -lo'
|
2007-04-16 20:54:37 +02:00
|
|
|
whence -p rot13 >/dev/null || alias rot13='tr [A-Za-z] [N-ZA-Mn-za-m]'
|
|
|
|
whence -p hd >/dev/null || alias hd="hexdump -e '"'"%08.8_ax " 8/1 '\
|
|
|
|
'"%02X " " - " 8/1 "%02X "'"' -e '\" |\" \"%_p\"' -e '\"|\\n\"'"
|
2006-07-23 20:44:22 +02:00
|
|
|
|
2006-08-14 22:32:44 +02:00
|
|
|
# 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
|
2006-07-23 20:44:22 +02:00
|
|
|
{
|
• remove strcasestr.c, use home-grown implementation¹, call it stricmp,
and have it return an API-correct const char *
• enhance and stylify comments
• a little KNF and simplifications
• #ifdef DEBUG: replace strchr and strstr with ucstrchr and ucstrstr
that take and return a non-const char *, and fix the violations
• new cstrchr, cstrstr (take and give const char *)
• new vstrchr, vstrstr (take const or not, give boolean value)
• new afreechk(x) = afreechv(x,x) = if (x1) afree(x2, ATEMP)
• new ksh_isdash(str) = (str != NULL) && !strcmp(str, "-")
• replace the only use of strrchr with inlined code to shrink
• minor man page fixes
• Minix 3 signames are autogenerated with gcc
• rename strlfun.c to strlcpy.c since we don't do strlcat(3) anyway,
only strlcpy(3), and shorten it
• dot.mkshrc: move MKSH=… down to the export line
to not disturb the PS1 visual impression ☺
• dot.mkshrc: Lstripcom(): optimise
• bump version
¹) side effect from creating API-correct cstrchr, cstrstr, etc.
uses goto so it must be better ☻
tested on mirbsd-current via both Makefile and Build.sh
2007-03-04 04:04:28 +01:00
|
|
|
cat "$@" | { set -o noglob; while read _line; do
|
2006-07-23 20:44:22 +02:00
|
|
|
_line=${_line%%#*}
|
|
|
|
[[ -n $_line ]] && print -r -- $_line
|
• remove strcasestr.c, use home-grown implementation¹, call it stricmp,
and have it return an API-correct const char *
• enhance and stylify comments
• a little KNF and simplifications
• #ifdef DEBUG: replace strchr and strstr with ucstrchr and ucstrstr
that take and return a non-const char *, and fix the violations
• new cstrchr, cstrstr (take and give const char *)
• new vstrchr, vstrstr (take const or not, give boolean value)
• new afreechk(x) = afreechv(x,x) = if (x1) afree(x2, ATEMP)
• new ksh_isdash(str) = (str != NULL) && !strcmp(str, "-")
• replace the only use of strrchr with inlined code to shrink
• minor man page fixes
• Minix 3 signames are autogenerated with gcc
• rename strlfun.c to strlcpy.c since we don't do strlcat(3) anyway,
only strlcpy(3), and shorten it
• dot.mkshrc: move MKSH=… down to the export line
to not disturb the PS1 visual impression ☺
• dot.mkshrc: Lstripcom(): optimise
• bump version
¹) side effect from creating API-correct cstrchr, cstrstr, etc.
uses goto so it must be better ☻
tested on mirbsd-current via both Makefile and Build.sh
2007-03-04 04:04:28 +01:00
|
|
|
done; }
|
2006-07-23 20:44:22 +02:00
|
|
|
}
|
2007-03-04 07:20:48 +01:00
|
|
|
|
2007-04-16 20:54:37 +02:00
|
|
|
# place customisations between this line and the ": RCSID" line below
|
2007-03-04 07:20:48 +01:00
|
|
|
|
2007-04-16 20:54:37 +02:00
|
|
|
: $MirOS: src/bin/mksh/dot.mkshrc,v 1.9 2007/04/16 18:54:37 tg Exp $
|