Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 18 Aug 2004 12:05:28 +0300 (EEST)
From:      Giorgos Keramidas <keramida@ceid.upatras.gr>
To:        Duane Winner <duanewinner@att.net>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: xtset or xtermset tricks?
Message-ID:  <20040818115550.T4343@orion>
In-Reply-To: <4122B61B.1050608@att.net>
References:  <41222679.7080000@att.net> <4122351E.7040205@att.net> <20040817165757.GA88222@thought.org> <4122B61B.1050608@att.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On 2004-08-17 21:51, Duane Winner wrote:
> Gary Kline wrote:
>> On Tue, Aug 17, 2004 at 12:41:02PM -0400, Duane Winner wrote:
>>> Found a solution!
>>>
>>> In ~/.bashrc, put this:
>>>
>>> cd ()
>>> {
>>>   builtin cd "$@"
>>>   /usr/local/bin/xtset %u@%h:`pwd`
>>> }

>> 	I've got a slight problem with having the host/directory/etc on the
>> 	title bar. It will help clear my zsh right-prompt, of course.

> But now, since I hammered out that little cd() function for .bashrc, I
> found another little problem:
>
> If I su to another user (for instance, "su - root"), the title changes
> as long as the other account has my the function in .bashrc, but when
> I exit, the title still has the old credentials (example:
> root@mybox:~) until I cd somewhere again. Sigh.

Don't use cd aliases for showing the current path in your xterm
titlebar.  There's a more elegant way involving PROMPT_COMMAND:

     bash-2.05b$ export PS1='\$ '
     $ export PROMPT_COMMAND='echo ::`pwd`::'
     ::/home/keramida::
     $ cd /etc
     ::/etc::
     $ cd /usr/src
     ::/usr/src::
     $ exit
     exit

You can set PROMPT_COMMAND to any command you want, no matter how
complicated.  A nice wrapper script around your "usual stuff" for
PROMPT_COMMAND can be called too with:

     $ export PROMPT_COMMAND='/home/keramida/bin/promptcmd.sh'

Regarding the current username, host name and directory, you might be
interested in this output too:

     $ echo $USER
     keramida
     $ hostname -s
     orion
     $ echo $PWD
     /home/keramida
     $

- Giorgos



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040818115550.T4343>