[NTLUG:Discuss] Re: Bash can put the current command into your xterm title
Steve Baker
sjbaker1 at airmail.net
Tue Aug 20 22:19:20 CDT 2002
Lance Simmons wrote:
> On Tue, Aug 20, 2002 at 09:42:28PM -0500, Steve Baker wrote:
>
>>Lance Simmons wrote:
>>
>>
>>>The basic idea is simple: you just have to get the escape characters
>>>right.
>>
>>I've been using a trick like this for about the last 15 years
>
>
> Were you able to do it with bash before 2.05b?
I use csh or tcsh - but the technique doesn't depend on any special
shell features. So long as your shell supports 'alias', you can always
alias the 'cd' command to mean:
1) run the *real* cd command ...then...
2) run my C program to change the banner to the result of running pwd
Then you make similar aliases for pushd and popd, rlogin, ssh and any other
commands that might be likely to change the contents of your banner.
So if bash had aliases back then, my trick should work just fine.
The critical dependancy is whether your Xterm equivelent (eg KDE's Konsole)
supports an escape sequence to write text into the banner. If it does, this
approach will work - if it doesn't then you're doomed. There are an annoyingly
large number of incompatible Xterm-like gadgets though - and for some inexplicable
reason, they've all chosen different escape sequences for this function.
My C program just takes its command line arguments and echoes them into
the banner - using an escape sequence that's determined from some environment
variables that get passed around via yet other backdoor mechanisms so that they
persist across remote logins and 'su' commands. You could probably use a shell
script for this - but I prefer writing C code where I can.
The Emacs macro rebinds the emacs open-file stuff to try to set the right filename
into the banner - 'vi' editing is handled with an alias that saves the current
banner settings, changes the banner to reflect the file thats' being edited
and then restores the banner after vi exits. It doesn't work if you switch
to editing a different file in mid-edit - but that's life.
This solution is a very personal one - it's not very configurable to other
people's tastes and there are ways to break it (like making other aliases
for directory-changing commands) that are things I don't happen to do.
----------------------------- Steve Baker -------------------------------
Mail : <sjbaker1 at airmail.net> WorkMail: <sjbaker at link.com>
URLs : http://www.sjbaker.org
http://plib.sf.net http://tuxaqfh.sf.net http://tuxkart.sf.net
http://prettypoly.sf.net http://freeglut.sf.net
http://toobular.sf.net http://lodestone.sf.net
More information about the Discuss
mailing list