Shell tcsh: title update

Hello all,

I'm trying to setup window title update when I run programs which doesn't update title by themselves.
For example, when I start vim, it updates title to something like: testfile.txt (~) VIM. But when I start top, window title stay unchanged. In case I have a lot of minimized terminal emulator windows and they have the same title, it's difficult enough to find where exatly the window with needed program running.

So, I solved this problem by adding following lines to ~/.tcshc:
Code:
if ($?prompt3) then
    set echo_style=both
    alias postcmd 'echo -n "\033]2;${HOST}: \!#:0:q\007"'
endif

In case of the program doesn't update title, tcsh changing it to: $HOST + command name without arguments. $HOST is needed to indicate on which one server command is running.
Everything works fine except one very annoing thing: in the tcsh history some commands saved two times. First time - command with arguments, second time - command without aguments + #+number.
Code:
$ history 5
  4928    8:59    ls -la
  4929    8:59    ls#+1675925966
  4930    8:59    dmesg
  4931    8:59    history 5

Is there a way to solve this problem?

Thank you!
 
I'd try \!#:0:p:q\007
(instead of \!#:0:q\007)

In the past, there has been some mangling of the history list when using modifiers, for example History breaks when using modifiers :gx, :l... #37

I'd like to know the output of: tcsh --version and which ls
Did you notice any pattern as to which commands get "mangled" in the history list?

If you can get this history mangling fairly consistent/repeatable, I'd, just as a test and without starting Xorg, set the alias postcmd with your history reference to the command name and see if the same mangling of the history list occurs. If that's the case, you'll have identified the problem outside the use of X.

If you don't get this resolved, I'd suggest opening a new issue at github - tcsh

edit:
I don't have any experience with prompt3, but tcsh(1):
Code:
Special shell variables
[...]
 prompt3 (+)
	       The string with	which  to  prompt  when confirming  automatic
	       spelling	 correction.  The same format sequences	may be used as
	       in prompt (q.v.); note the variable meaning of  `%R'.   Set  by
	       default to `CORRECT>%R (y|n|e|a)? ' in interactive shells.
suggests to me that when things like spelling correction is involved, I'd try the more usual approach in testing $TERM as SirDice mentioned below. Perhaps Xterm Title - 4.2 tcsh is also helpful.
 
I have this:
Code:
        switch($TERM)
                case "rxvt":
                case "screen*":
                case "xterm*":
                        set TITLE = "%{\033]0;%n@%m:%~\007%}"
                        breaksw
                default:
                        set TITLE = ""
                        breaksw
        endsw

        set prompt = "${TITLE}%B%n@%m%b:%c03 %# "
But this only sets the title the same as the prompt. And only if I'm actually in an environment where it makes sense.
 
I'd try \!#:0:p:q\007
(instead of \!#:0:q\007)
The history still merges with timestamp.
In the past, there has been some mangling of the history list when using modifiers, for example History breaks when using modifiers :gx, :l... #37
It looks like I have similar problem but with other modifiers.
I'd, just as a test and without starting Xorg
I use x11-wm/sway, but I'll try to test in the console before sway start.
I'd like to know the output of: tcsh --version and which ls
Code:
iron@IRON:~ $ tcsh --version
tcsh 6.22.04 (Astron) 2021-04-26 (x86_64-amd-FreeBSD) options wide,nls,dl,al,kan,sm,rh,color,filec
iron@IRON:~ $ which ls
ls:     aliased to ls -G
iron@IRON:~ $ alias ls
ls -G
iron@IRON:~ $ env LANG=C which ls
/bin/ls
$ uname -a
FreeBSD IRON 13.2-PRERELEASE FreeBSD 13.2-PRERELEASE #13 stable/13-n254388-6b9f6aeac69b: Mon Feb  6 22:27:29 EET 2023     root@IRON:/usr/obj/usr/src/amd64.amd64/sys/IRON amd64
I'd try the more usual approach in testing $TERM as SirDice mentioned below.
I'll try, thank you.
 
I've tried everything proposed in this topic but non of them works. It seems it's bug of tcsh, going to create an issue.
In case I won't solve this problem, unfortunately I'll have to move to another shell like bash or zsh.
Thanks for your answers.
 
Back
Top