For When You Can't Have The Real Thing
[ start | index | login ]
start > Linux > screen > Screen Session and Window Titles

Screen Session and Window Titles

Created by dave. Last edited by dave, 119 days ago. Viewed 164 times. #4
[diff] [history] [edit] [rdf]
labels
attachments
(2020-02-04)

Problem

Terminal window titles and screen session titles are different things. At some point, Redhat/Fedora changed what the PROMPT_COMMAND emitted by default.

Solution

In a login shell startup dotfile (for example, I put mine in a >>file I put in /etc/profile.d):

# Screen session and terminal window titles
#  This "should" be reasonably portable/harmless-to-systems-that-don't-understand
# If we are interactive
if [ "$PS1" ]; then
  # Print out a string for screen to print as a session title,
  #  then print out a string for putty/kitty/xterm to use as a window title.
  if [ "$PS1" ]; then
  # If we are in a screen session, print out an escape sequence for the screen session title.
  # Either way, print out an escape sequence for putty/kitty/xterm to use as a window title.
  PROMPT_COMMAND='if [ "$TERM" == "screen" ] ;then \
    printf "\033k%s@%s:%s\033\\" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"; \
  fi; \
  printf "\033]0;%s@%s:%s007" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"'
fi

For screen, this sets a value that screen displays in the hardstatus line as "%t".

Commentary

Goddamn it, RedHat.

no comments | post comment
This is a collection of techical information, much of it learned the hard way. Consider it a lab book or a /info directory. I doubt much of it will be of use to anyone else.

Useful:


snipsnap.org | Copyright 2000-2002 Matthias L. Jugel and Stephan J. Schmidt