use string width, not length, if we have it
This commit is contained in:
12
dot.mkshrc
12
dot.mkshrc
@ -1,5 +1,5 @@
|
|||||||
# $Id$
|
# $Id$
|
||||||
# $MirOS: src/bin/mksh/dot.mkshrc,v 1.55 2010/07/04 17:35:16 tg Exp $
|
# $MirOS: src/bin/mksh/dot.mkshrc,v 1.56 2010/07/11 13:54:37 tg Exp $
|
||||||
#-
|
#-
|
||||||
# Copyright (c) 2002, 2003, 2004, 2006, 2007, 2008, 2009, 2010
|
# Copyright (c) 2002, 2003, 2004, 2006, 2007, 2008, 2009, 2010
|
||||||
# Thorsten Glaser <tg@mirbsd.org>
|
# Thorsten Glaser <tg@mirbsd.org>
|
||||||
@ -31,7 +31,7 @@ function precmd {
|
|||||||
}
|
}
|
||||||
PS1='
|
PS1='
|
||||||
$(precmd)${USER:=$(ulimit -c 0;id -un 2>&-||print \?)}@${HOSTNAME%%.*}:$(
|
$(precmd)${USER:=$(ulimit -c 0;id -un 2>&-||print \?)}@${HOSTNAME%%.*}:$(
|
||||||
typeset d=${PWD:-?} n p=~; [[ $p = ?(*/) ]] || d=${d/#$p/~}
|
typeset d=${PWD:-?} n p=~; [[ $p = ?(*/) ]] || d=${d/#$p/~}
|
||||||
(( (${%d}>0 ? ${%d}: ${#d}) > (n = (COLUMNS/3<7 ? 7: COLUMNS/3)) )) && {
|
(( (${%d}>0 ? ${%d}: ${#d}) > (n = (COLUMNS/3<7 ? 7: COLUMNS/3)) )) && {
|
||||||
d=${d:(-n)}; p=...; } || p=; print -nr -- "$p$d") '"$PS1 "
|
d=${d:(-n)}; p=...; } || p=; print -nr -- "$p$d") '"$PS1 "
|
||||||
: ${MKSH:=$(whence -p mksh)}; export EDITOR HOSTNAME MKSH PS1 TERM USER
|
: ${MKSH:=$(whence -p mksh)}; export EDITOR HOSTNAME MKSH PS1 TERM USER
|
||||||
@ -73,7 +73,7 @@ function cd_csh {
|
|||||||
fi
|
fi
|
||||||
cd "$t"
|
cd "$t"
|
||||||
}
|
}
|
||||||
function dirs {
|
function dirs {
|
||||||
typeset d dwidth
|
typeset d dwidth
|
||||||
typeset -i isnoglob=0 fl=0 fv=0 fn=0 cpos=0
|
typeset -i isnoglob=0 fl=0 fv=0 fn=0 cpos=0
|
||||||
|
|
||||||
@ -105,9 +105,11 @@ function dirs {
|
|||||||
fv=0
|
fv=0
|
||||||
while (( fv < ${#DIRSTACK[*]} )); do
|
while (( fv < ${#DIRSTACK[*]} )); do
|
||||||
d=${DIRSTACK[fv]}
|
d=${DIRSTACK[fv]}
|
||||||
(( fl )) && d=${d/#~/$DIRSTACKBASE}
|
(( fl )) && d=${d/#~/$DIRSTACKBASE}
|
||||||
|
(( dwidth = (${%d} > 0 ? ${%d} : ${#d}) ))
|
||||||
|
if (( fn && (cpos += dwidth + 1) >= 79 && \
|
||||||
dwidth < 80 )); then
|
dwidth < 80 )); then
|
||||||
print
|
print
|
||||||
(( cpos = dwidth + 1 ))
|
(( cpos = dwidth + 1 ))
|
||||||
fi
|
fi
|
||||||
print -nr -- "$d "
|
print -nr -- "$d "
|
||||||
|
Reference in New Issue
Block a user