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

Re: setting dynamic rxvt titles with Xresoures/Xdefaults



Christophe Broult wrote:

> "Jens B. Jorgensen" <jjorgens@bdsinc.com> writes:
>
> [snip]
>
> > with your user name, current directory, etc. then what you need to do is use the bash
> > PROMPT_COMMAND. bash runs the contents of this variable each time the prompt is
> > printed (you could achieve similar effect using the PS1 variable). Here's a snip from
> > a .bash_profile to get you started:
> >
> > if [ "$TERM" = "xterm" -o "$TERM" = "xterm-color" -o \
> >      "$TERM" = "rxvt"  -o "$TERM" = "vs100" ]
> > then
> >    HOST=`hostname`
> >    USER=${USER:-$(whoami)}
> >    export PROMPT_COMMAND='echo -ne "\033]0;$HOST($USER):$PWD\007"'
> > fi
> >
> > What's that? You don't run bash? If you don't run bash I don't know how to make your
> > shell do this. With ksh you should be able to get things working using the PS1
> > variable.
>
> As you seem pretty knowledgeable with bash usage, I have a question:
>
> In my .bashrc I have:
>
> PS1='\u@\h:\w \$ '
>
> So I get a prompt including a tilde in the prompt when the current
> directory is under my home directory, ie ~/foo instead of
> /home/broult/foo
>
> Do you know how I can get the same behavior with the command you just
> written for the PROMPT_COMMAND variable?

I do love a challenge! The replacement of your home directory seems peculiar to the '\w'
expansion which only takes place in PS1. However, this peculiarity *also* exists in the
DIRSTACK which bash keeps. The solution to your problem is:

export PROMPT_COMMAND='echo -ne "\033]0;$HOST($USER):$(dirs +0)\007"'

I'm glad you asked this. Now I'll change my own settings too!

--
Jens B. Jorgensen
jjorgens@bdsinc.com



--  
Unsubscribe?  mail -s unsubscribe debian-user-request@lists.debian.org < /dev/null


Reply to: