Next: , Previous: Title Command, Up: Naming Windows


10.1.2 Dynamic Titles

screen has a shell-specific heuristic that is enabled by setting the window's name to search|name and arranging to have a null title escape-sequence output as a part of your prompt. The search portion specifies an end-of-prompt search string, while the name portion specifies the default shell name for the window. If the name ends in a ‘:screen will add what it believes to be the current command running in the window to the end of the specified name (e.g. name:cmd). Otherwise the current command name supersedes the shell name while it is running.

Here's how it works: you must modify your shell prompt to output a null title-escape-sequence (<ESC> k <ESC> \) as a part of your prompt. The last part of your prompt must be the same as the string you specified for the search portion of the title. Once this is set up, screen will use the title-escape-sequence to clear the previous command name and get ready for the next command. Then, when a newline is received from the shell, a search is made for the end of the prompt. If found, it will grab the first word after the matched string and use it as the command name. If the command name begins with ‘!’, ‘%’, or ‘^’, screen will use the first word on the following line (if found) in preference to the just-found name. This helps csh users get more accurate titles when using job control or history recall commands.