I set up my tcsh xterm to update the titlebar on "postcmd" with the name of the last command that was run and the directory.
This is similar to what I had (minimal example to reproduce):
alias postcmd 'echo -n "\033]0;hello_world\007";'
(note that this alias is in my .cshrc file. If just I type this on the command line, than it works 100% properly)
This successfully updates the xterm titlebar to say "hello_world" after every command that I run, except for less
When I run less
, I get the following terminal output:
>less abc.txt
ESC]0;hello_world^GESC]0;hello_world^GESC]0;hello_world^GESC]0;hello_world^GESC]0;hello_world^GESC]0;hello_world^GESC]0;hello_world^GESC]0;hello_world
^GESC]0;hello_world^GESC]0;hello_world^GESC]0;hello_world^GESC]0;hello_world^GESC]0;hello_world^G...
(END)
The file never actually opens, it just prints this garbage string and I have to CTRL-C
to cancel it. Is the bell or escape character messing up the initialization of less somehow? Any idea how I can modify this to not break less
? I could just as easily use another editor, but sometimes I need to share my console with other engineers for debugging and I don't want to confuse them if they choose to run less
.
This is the actual code I am using, which has the same issue as the simple hello_world example:
alias postcmd 'set HIST = `history -h 1`; printf "\033]0;%s\007" "xterm: $HIST @ $cwd ";'
=====EDIT===== Some additional info:
> alias less
> echo $LESS
LESS: Undefined variable
> echo $TERM
xterm
>less --version
less 382
Copyright (C) 2002 Mark Nudelman
less comes with NO WARRANTY, to the extent permitted by law.
For information about the terms of redistribution,
see the file named README in the less distribution.
Homepage: http://www.greenwoodsoftware.com/less
>tcsh --version
tcsh 6.13.00 (Astron) 2004-05-19 (x86_64-unknown-linux) options 8b,nls,dl,al,kan,rh,color,dspm,filec
=== MORE EDIT ===
On further debugging, I find that the problem only occurs when I put the command in my .cshrc file. If I uncomment the alias from .cshrc, and simply type the alias on the command line, then it works properly with less.
Also, having put the alias in my .cshrc , if I unalias it, it still breaks less even after being unaliased. So it seems the problem is not coming from the presence of the alias, but from being aliased while .cshrc is being executed on terminal creation?