2007-05-19 18:33:10 +02:00
|
|
|
: ${EDITOR:=/bin/ed} ${TERM:=vt100} ${HOSTNAME:=$(ulimit -c 0;hostname -s 2>&-)}
|
|
|
|
[[ $HOSTNAME = @(localhost|*([ ])) ]] && HOSTNAME=$(ulimit -c 0;hostname 2>&-)
|
2007-06-20 15:38:18 +02:00
|
|
|
: ${HOSTNAME:=nil}; PS1='#'; [[ "$(ulimit -c 0; id -u 2>&-)" -eq 0 ]] || PS1='$'
|
2007-06-16 00:00:00 +02:00
|
|
|
PS1='$(((e = $?)) && print $e\|)${USER:=$(ulimit -c 0; id -un 2>&- || \
|
2007-07-26 15:37:21 +02:00
|
|
|
print nobody)}@${HOSTNAME%%.*}:$(typeset pfx=~ wd=${PWD:-?}
|
2007-06-16 00:00:00 +02:00
|
|
|
typeset -i n=${COLUMNS:-80}/3; let n="n < 7 ? 7 : n"
|
2006-07-23 20:44:22 +02:00
|
|
|
[[ ${wd#$pfx} = $wd || $pfx = ?(/) ]] || wd=\~${wd#$pfx}
|
2007-05-19 18:33:10 +02:00
|
|
|
pfx=; while (( (${#pfx} + ${#wd}) > n )); do
|
2006-07-23 20:44:22 +02:00
|
|
|
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
|
2007-06-20 15:38:18 +02:00
|
|
|
done; print -r -- "$pfx$wd") '"$PS1 "
|
2007-04-17 22:07:09 +02:00
|
|
|
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-05-25 15:51:42 +02:00
|
|
|
alias which='whence -p'
|
2007-05-19 18:33:10 +02:00
|
|
|
whence -p rot13 >&- || alias rot13='tr [A-Za-z] [N-ZA-Mn-za-m]'
|
|
|
|
whence -p hd >&- || function hd {
|
2007-04-17 22:00:37 +02:00
|
|
|
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
|
2007-04-17 22:04:08 +02:00
|
|
|
function Lstripcom {
|
• 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-17 22:07:09 +02:00
|
|
|
# place customisations between this line and the “: RCSID” line below
|
2007-03-04 07:20:48 +01:00
|
|
|
|
2007-07-26 15:37:21 +02:00
|
|
|
: $MirOS: src/bin/mksh/dot.mkshrc,v 1.18 2007/07/26 13:37:21 tg Rel $
|