[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: xterm title bar change and prompt change



On Mon, Dec 06, 1999 at 03:32:56PM -0600, ktb wrote:
> This may be hard to explain but I'll try.  I have this in my
> /home/kent/.bashrc,
> 
> case $TERM in
>      xterm*)
>          PS1="\[\033]0;\u@\h: \w\007\]\w\$ "
>          ;;
>      *)
>          PS1="\w\$ "

If you check, you'll notice that the $PS1 variable contains just a $
character, not a \$ sequence. This is the problem. The reason for this
is that bash is interpreting "\$" to mean the $ character, since $ is
normally a metacharacter. So, you either have to enclose it in single
quotes (so it won't interpret any metachatacters) or you have to put in
the \\ sequence to get the actual \ in the string.

For example,
  $ su -
  Password: 
  # PS1="\w\$ "
  ~$ echo $PS1
  \w$
  ~$ PS1="\w\\\$ "
  ~# echo $PS1
  \w\$
  ~# PS1='\w\$ '
  ~# echo $PS1
  \w\$
  ~# 


-- 
  finger for GPG public key.
  29 Nov 1999 - new email address added to gpg key

Attachment: pgpKTy1RzroRa.pgp
Description: PGP signature


Reply to: