How to automatically update the title in an xterm running screen

gnu-screentcshxterm

This is a bit of a followup to this question. I'm working in tcsh within GNU screen in an xterm.

I have the following in my .cshrc:

alias res_t 'xtset -t %h:%d "(%u:%g)" %e'       # reset titlebar
res_t                                           # reset title right now
alias precmd res_t

And this works fine!

However, when I run screen I see that the title doesn't get updated with the current directory. How can I make screen update the xterm title?

Best Answer

You can set the xterm window title by adding this to your .tcshrc or .cshrc (replace your current precmd alias):

alias precmd 'echo -n "\033]0;${PWD}\a"'

Make sure this is the only precmd alias in your .cshrc and .tcshrc files when using this. This method displays the current directory as the window title for me in both xterm a gnome-terminal regardless of whether a GNU screen session is open.

My answer was based on this.

Related Question