Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Printing command and arguments on xterm frame.



I just upgraded to zsh-3.0.2 and there is some functionality I have
been wanting from zsh for quit a while:

Whenever a command is run, I would like to have the command and its
arguments to be displayed on the xterm titlebar and the icon bar.

Currently, I do it for some commands, like less, with the following
function:

function less()
{
xtitle "${HOST}: $0 $*"
command $0 $*
}

where xtitle is a function that updates the xterm titlebar and icon
title.


For some specific cases, I do the following:

xtitle "command args"; command args

which gives me the wanted result.  When I use several xterms on
different machines, this gives me the information I need to quickly
retrieve the appropriate xterm.

I would like zsh to do this for me automatically...

I thought about using the precmd function, but it does not work as
precmd is executed before printing the prompt, therefore before the
command and its arguments are known.

I wonder if there already is a mechanism in the current version of zsh
that would allow me to have the xterm titlebar updated for the
duration of the command.  I suspect the answer is no.

If it is not the case, I would propose to have a function, let's call
it pre-cmd-hook, that if defined, is invoked after the command is entered
but before executing it.

Maybe, after the zle extension proposed by Zefram, there is no need
for the precmd2 function.  Binding the ^J and ^M keys to a zle
function that prints the command line and call accept-line would do
the trick.

Any comment, idea, suggestion on this?  Does it seem to be a good idea
to implement the pre-cmd-hook stuff or is it better to wait until the
zle expension is released?

If the zsh community thinks it is a good idea to implement
pre-cmd-hook stuff, I will try to implement it.  That will be my first
attempt to modify zsh code :-)


Merry Xmas to everyone.


Alain Caron,
email: alainc@xxxxxxxxx
phone: 514-765-7718

"Violence on television only affect children whose parents behave like
TV characters" - David Byrne



Messages sorted by: Reverse Date, Date, Thread, Author