Mail Archives: cygwin/2000/07/11/13:16:35
: >Bonjour:
: >
: >I set `PS1' as
: >
: >PS1='\e]0;\H:\w\007GENERIC> '
: >
: >It works fine for small line command.
: >But if the line command is to long (higher then half a line)
: >strange behaviours happen:
: ...
:
: Although you don't see the escape-codes in your prompt they are taken
: into account when calculating the length of the current commandline it
: seems. I solved the problem in the following way:
: ...
Bash provides syntax deliberately to exclude PS1 parts from counting on
the column width:
\[...\]
My prompt setting is attached below (a lot of stuff to safely include
some info I like to see). The only problem I have is that \w doesn't
behave well if the prompt really (i.e., visible part only) exceeds the
terminal width in deep directory trees.
Kind regards,
Thomas Wolff
-----------------------------------------------------------------------------
HOSTNAME=${HOSTNAME-`hostname`}
user=`id -u -n`
case $user in
root) rootmark="30;41"; dirmark=7;;
*) rootmark=0; dirmark=7;;
esac
if [ "$user" != "$USER" -a "$USER" != "" ]
then user=$user/$USER
fi
case $TERM in
xterm*) colour=
case $HOSTNAME in
scotty*) colour="black;gray65";;
*) case "$OS" in
SunOS) colour="sienna2;black";;
HP-UX) colour="black;bisque3";;
esac
esac
PS1="\[]10;$colour\]$clearprompt\[[${rootmark}m\]$user\[[0m\]@$HOSTNAME:\[[${dirmark}m\]\w\[[0m\]> \[]2;$user@$HOSTNAME:\w]1;\W\]"
unset colour
;;
*) case "$OS" in
Linux) case `tty` in
/dev/tty?) cono=.`tty | sed -e "s,/dev/tty,,"`;;
*) cono=;;
esac;;
*) cono=;;
esac
PS1=$clearprompt"\[[${rootmark}m\]$user\[[0m\]@$HOSTNAME$cono:\[[${dirmark}m\]\w\[[0m\]> "
unset cono
;;
esac
unset rootmark
unset dirmark
unset user
export PS1
PROMPT_COMMAND=
-----------------------------------------------------------------------------
--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com
- Raw text -