[Midnightbsd-cvs] src: dot.mkshrc: update dot.mkshrc for r36b.
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Sat Mar 28 22:51:28 EDT 2009
Log Message:
-----------
update dot.mkshrc for r36b. Add a custom setvar function for freebsd compatibility.
Modified Files:
--------------
src/etc/root:
dot.mkshrc (r1.1 -> r1.2)
-------------- next part --------------
Index: dot.mkshrc
===================================================================
RCS file: /home/cvs/src/etc/root/dot.mkshrc,v
retrieving revision 1.1
retrieving revision 1.2
diff -L etc/root/dot.mkshrc -L etc/root/dot.mkshrc -u -r1.1 -r1.2
--- etc/root/dot.mkshrc
+++ etc/root/dot.mkshrc
@@ -1,58 +1,27 @@
# $MidnightBSD$
-# $MirOS: src/bin/mksh/dot.mkshrc,v 1.28 2008/03/01 21:24:58 tg Rel $
+# $MirOS: src/bin/mksh/dot.mkshrc,v 1.39 2008/12/13 17:09:45 tg Rel $
#-
-# Copyright (c) 2007, 2008
-# Thorsten “mirabilos” Glaser <tg at mirbsd.de>
-#
-# Provided that these terms and disclaimer and all copyright notices
-# are retained or reproduced in an accompanying document, permission
-# is granted to deal in this work without restriction, including un-
-# limited rights to use, publicly perform, distribute, sell, modify,
-# merge, give away, or sublicence.
-#
-# Advertising materials mentioning features or use of this work must
-# display the following acknowledgement:
-# This product includes material provided by Thorsten Glaser.
-#
-# This work is provided "AS IS" and WITHOUT WARRANTY of any kind, to
-# the utmost extent permitted by applicable law, neither express nor
-# implied; without malicious intent or gross negligence. In no event
-# may a licensor, author or contributor be held liable for indirect,
-# direct, other damage, loss, or other issues arising in any way out
-# of dealing in the work, even if advised of the possibility of such
-# damage or existence of a defect, except proven that it results out
-# of said person's immediate fault when using the work as intended.
-#-
-# sample mksh initialisation file for interactive shells; install as
-# /etc/skel/.mkshrc (as root, for new accounts) or copy to ~/.mkshrc
+# ~/.mkshrc: mksh initialisation file for interactive shells
: ${EDITOR:=/bin/ed} ${TERM:=vt100} ${HOSTNAME:=$(ulimit -c 0;hostname -s 2>&-)}
[[ $HOSTNAME = @(localhost|*([ ])) ]] && HOSTNAME=$(ulimit -c 0;hostname 2>&-)
-: ${HOSTNAME:=nil}; PS1='#'; [[ "$(ulimit -c 0; id -u 2>&-)" -eq 0 ]] || PS1='$'
+: ${HOSTNAME:=nil}; if (( USER_ID )); then PS1='$'; else PS1='#'; fi
function precmd {
- typeset -Ui10 e=$?
+ typeset -i e=$?
(( e )) && print -n "$e|"
}
-PS1='$(precmd)${USER:=$(ulimit -c 0;id -un 2>&- || print \?)}@${HOSTNAME%%.*}:$(
- typeset pfx=~ wd=${PWD:-?}
- typeset -Ui n=${COLUMNS:-80}/3; (( n = n < 7 ? 7 : n ))
- wd=${wd/#$pfx/~}
- pfx=; while (( (${#pfx} + ${#wd}) > n )); do
- if [[ $wd = */* ]]; then
- pfx=.../
- wd=${wd#*/}
- else
- pfx=...
- wd=${wd#?????}
- fi
- done; print -nr -- "$pfx$wd") '"$PS1 "
-PS1="$(print -n '\x1\r')$PS1" # allow colour codes, framed with ^A
+PS1='
$(precmd)${USER:=$(ulimit -c 0;id -un 2>&-||print \?)}@${HOSTNAME%%.*}:$(
+ typeset p=~ d=${PWD:-?}; typeset -i n=${COLUMNS:-80}/3
+ [[ $p = ?(*/) ]] || d=${d/#$p/~}; (( n=n<7?7:n )); (( ${#d}>n )) && {
+ p=...; d=${d:(-n)}; } || p=; print -nr -- "$p$d") '"$PS1 "
export EDITOR HOSTNAME LESSHISTFILE=- MKSH=$(whence -p mksh) PS1 TERM USER
+alias ls=ls
+unalias ls
alias l='/bin/ls -F'
alias la='l -a'
alias ll='l -l'
-alias lo='la -lo'
+alias lo='l -alo'
alias which='whence -p'
whence -p rot13 >&- || alias rot13='tr \
abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ \
@@ -64,12 +33,12 @@
# Berkeley C shell compatible dirs, popd, and pushd functions
# Z shell compatible chpwd() hook, used to update DIRSTACK[0]
-DIRSTACKBASE=$(readlink -nf ~/. 2>&- || print -nr -- "$HOME")
-typeset -r DIRSTACKBASE
+DIRSTACKBASE=$(realpath ~/. 2>&- || print -nr -- "$HOME")
set -A DIRSTACK
function chpwd {
- DIRSTACK[0]=$(readlink -nf . 2>&- || print -r -- "$PWD")
- DIRSTACK[0]=${DIRSTACK[0]/#$DIRSTACKBASE/~}
+ DIRSTACK[0]=$(realpath . 2>&- || print -r -- "$PWD")
+ [[ $DIRSTACKBASE = ?(*/) ]] || \
+ DIRSTACK[0]=${DIRSTACK[0]/#$DIRSTACKBASE/~}
:
}
chpwd .
@@ -90,7 +59,7 @@
typeset d
typeset -i isnoglob=0 fl=0 fv=0 fn=0 cpos=0
- [[ $(set +o) == *-o\ noglob* ]] && isnoglob=1
+ [[ $(set +o) == *@(-o noglob)@(| *) ]] && isnoglob=1
set -o noglob
while getopts ":lvn" d; do
case $d {
@@ -135,7 +104,7 @@
typeset d fa
typeset -i isnoglob=0 n=1
- [[ $(set +o) == *-o\ noglob* ]] && isnoglob=1
+ [[ $(set +o) == *@(-o noglob)@(| *) ]] && isnoglob=1
set -o noglob
while getopts ":0123456789lvn" d; do
case $d {
@@ -174,7 +143,7 @@
typeset d fa
typeset -i isnoglob=0 n=1
- [[ $(set +o) == *-o\ noglob* ]] && isnoglob=1
+ [[ $(set +o) == *@(-o noglob)@(| *) ]] && isnoglob=1
set -o noglob
while getopts ":0123456789lvn" d; do
case $d {
@@ -216,6 +185,16 @@
dirs $fa
}
+# ash (freebsd) compatibility
+
+function setvar {
+ if [[ -z $2 ]]; then eval unset $1
+ elif [[ $1 != +([a-zA-Z0-9_]) ]]; then print -u2 -r -- "setvar: $1: bad variable name"; return 1
+ else
+ eval export $1=\$2
+ fi
+}
+
# 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 {
More information about the Midnightbsd-cvs
mailing list