I set my tcsh xterm to update the header on "postcmd" with the name of the last command and directory started.
This is similar to what I had (minimal example to play):
alias postcmd 'echo -n "\033]0;hello_world\007";'
(note that this alias is in my .cshrc file. If I just type it on the command line, then it works 100%)
This successfully updates the xterm header header 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 opens, it just prints this garbage line, and I need CTRL-C to undo it. Is a bell or a winning character somehow ruining the initialization? Any idea how I can change this so as not to break less ? I could just use a different editor, but sometimes I need to share my console with other engineers for debugging, and I don't want to confuse them if they decide to run less .
This is the actual code that I am using that has the same problem as the simple hello_world example:
alias postcmd 'set HIST = `history -h 1`; printf "\033]0;%s\007" "xterm: $HIST @ $cwd ";'
===== ===== EDIT Additional information:
> 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 ===
With further debugging, I find that the problem occurs when I put this command in a .cshrc file. If I uncomment the alias from .cshrc and just type the alias on the command line, then it works correctly with less.
Also, by putting an alias in my .cshrc, if I refuse it, it will still break less even after it is unaliased. Thus, it seems that the problem does not arise due to the presence of an alias, but from aliases, while .cshrc is executed when creating the terminal?