delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2000/07/11/13:16:35

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT sources DOT redhat DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT sources DOT redhat DOT com>
List-Help: <mailto:cygwin-help AT sources DOT redhat DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT sources DOT redhat DOT com
Delivered-To: mailing list cygwin AT sources DOT redhat DOT com
From: Thomas DOT Wolff AT icn DOT siemens DOT de
Date: Tue, 11 Jul 2000 19:03:58 +0200 (MEST)
Message-Id: <200007111703.TAA18143@mail.bln1.siemens.de>
Cc: michael-ring AT t-online DOT de (Michael Ring)
Cc: Jerome Benoit <JGMBenoit AT Wanadoo DOT fr>
To: cygwin AT sourceware DOT cygnus DOT com
Subject: 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 AT sourceware DOT cygnus DOT com

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019