From c79cacdfa55aa3fe042412ab4c269764201a8602 Mon Sep 17 00:00:00 2001 From: tg Date: Mon, 16 Apr 2007 18:54:37 +0000 Subject: [PATCH] =?UTF-8?q?=E2=80=A2=20from=20a=20MirOS=20point=20of=20vie?= =?UTF-8?q?w:=20=20=20place=20most=20stuff=20from=20/etc/profile=20in=20/e?= =?UTF-8?q?tc/skel/.mkshrc;=20admins=20must=20make=20=20=20sure=20to=20cop?= =?UTF-8?q?y=20this=20file=20to=20users'=20homes=20on=20upgrade=20(benefit?= =?UTF-8?q?:=20non-login=20but=20=20=20interactive=20shells=20also=20get?= =?UTF-8?q?=20all=20the=20goodies);=20fix=20some=20quoting;=20simplify,=20?= =?UTF-8?q?=20=20reformat,=20change=20comments=20=E2=80=A2=20from=20an=20m?= =?UTF-8?q?ksh=20point=20of=20view:=20=20=20slight=20internal=20changes=20?= =?UTF-8?q?in=20dot.mkshrc;=20external=20commands=20are=20now=20prefixed?= =?UTF-8?q?=20=20=20with=20=E2=80=9Culimit=20-c=200=E2=80=9D;=20$TERM=20is?= =?UTF-8?q?=20defined;=20improvement=20in=20determining=20the=20host=20=20?= =?UTF-8?q?=20name=20(e.g.=20on=20Debian=20if=20a=20FQDN=20is=20not=20give?= =?UTF-8?q?n);=20declare=20locals=20as=20such=20both=20=20=20in=20$PS1=20a?= =?UTF-8?q?nd=20outside;=20remove=20superfluous=20quoting,=20quote=20prope?= =?UTF-8?q?rly;=20simplify=20=20=20hd=20alias,=20add=20rot13=20alias;=20pl?= =?UTF-8?q?ace=20RCS=20ID=20at=20the=20bottom?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile | 6 +++++- dot.mkshrc | 36 ++++++++++++++++++++---------------- 2 files changed, 25 insertions(+), 17 deletions(-) diff --git a/Makefile b/Makefile index 61c3196..d6ed849 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -# $MirOS: src/bin/mksh/Makefile,v 1.35 2007/03/04 04:36:45 tg Exp $ +# $MirOS: src/bin/mksh/Makefile,v 1.36 2007/04/16 18:54:37 tg Exp $ #- # use CPPFLAGS=-DDEBUG __CRAZY=Yes to check for certain more stuff @@ -48,4 +48,8 @@ cleandir: clean-extra clean-extra: .PHONY -rm -rf build-dir regress-dir +distribution: + ${INSTALL} ${INSTALL_COPY} -o ${BINOWN} -g ${CONFGRP} -m 0644 \ + ${.CURDIR}/dot.mkshrc ${DESTDIR}/etc/skel/.mkshrc + .include diff --git a/dot.mkshrc b/dot.mkshrc index d959b7d..52fea24 100644 --- a/dot.mkshrc +++ b/dot.mkshrc @@ -1,30 +1,34 @@ -# $MirOS: src/bin/mksh/dot.mkshrc,v 1.8 2007/03/04 06:20:48 tg Exp $ - -: ${EDITOR:=/bin/ed} ${HOSTNAME:=$(hostname -s 2>/dev/null || hostname)} -PS1='$(((rv=$?)) && print $rv\|)${USER:=$(id -un)}@${HOSTNAME:=nil}:$( - local pfx=~ wd=${PWD:-$(pwd)} +: ${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 [[ ${wd#$pfx} = $wd || $pfx = ?(/) ]] || wd=\~${wd#$pfx} - pfx=; let n="( (n = ${COLUMNS:-80} / 3) < 7 ? 7 : n)" + pfx=; let n="n < 7 ? 7 : n" while (( (${#pfx} + ${#wd}) > n )); do if [[ $wd = */* ]]; then pfx=.../ - wd="${wd#*/}" + wd=${wd#*/} else pfx=... - wd="${wd#?????}" + wd=${wd#?????} fi done - print -r -- "$pfx$wd")'" $(if (( $(id -u) )); then - print \$; else print \#; fi) " -export EDITOR HOSTNAME MKSH=$(whence -p mksh) PS1 USER + print -nr -- "$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' -[ -x /usr/bin/hd ] || eval alias hd="'hexdump -e '\\''\"%08.8_ax \" 8/1" \ - '"%02X " " - " 8/1 "%02X "'"'\\'' -e '\\''"'" |" "%_p"'"'\\''" \ - "-e '\\''"'"|\n"'"'\\'' '" +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\"'" # 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 @@ -36,6 +40,6 @@ function Lstripcom done; } } -# Your shell code goes below! +# place customisations between this line and the ": RCSID" line below -: Your shell code goes above! +: $MirOS: src/bin/mksh/dot.mkshrc,v 1.9 2007/04/16 18:54:37 tg Exp $