This is the mail archive of the cygwin@sources.redhat.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: PS1 and Window title


: >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\[\]@$HOSTNAME:\[[${dirmark}m\]\w\[\]> \[]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\[\]@$HOSTNAME$cono:\[[${dirmark}m\]\w\[\]> "
	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@sourceware.cygnus.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]