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

RE: Changing xterm titles to something more usefull than 'xterm'



On 20-Apr-98 Norbert Veber wrote:
> Is there a simple way to make xterms display the current command
> beeing executed in the window? By simple I mean without patching and
> recompiling bash and/or xterm. I know that you can change the title
> using the -T command line option, but I want it to change dynamically
> depending on what I'm doing in that xterm. This would work nicelly
> with afterstep's window list module.  
> 
> To make it display the current path, something like this can be used 
> (in bash):
> PS1='(\u@\h:\w)% \[\033]0;\w\007\]'
> 
> But how can I make it display the name of the command?
> 

Changing the title bar dynamically can be done with the PROMPT_COMMAND
environment variable (in bash). In my bashrc I have:

function settitle
{
#  title="`whoami`@`hostname`:(`date +%k:%M:%S`):`pwd`"
  title="`whoami`@`hostname`:(`date +%k:%M:%S`):`history 1`"
  echo -n "^[]2;$title^G" > /dev/tty
}

if [ $TERM = "xterm" ] || [ $TERM = "xterm-color" ]; then
    PROMPT_COMMAND=settitle
    PS1='\h:\u > '
fi

The first title assignment is useful when I want to know the current
directory while having a small prompt. Also for telling when an xterm
was last used.

The second one only lists the last command executed. Don't know how to
list the current one.

Hope this helps!

(thanks go to Glynn Clements on linux-admin for this tid-bit)

Mike Brownlow <mike@ctelcom.net>


--
To UNSUBSCRIBE, email to debian-user-request@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org


Reply to: