xtset or xtermset tricks?

Giorgos Keramidas keramida at ceid.upatras.gr
Wed Aug 18 02:06:09 PDT 2004


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 at 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



More information about the freebsd-questions mailing list