Linux, musical road-dogging, and daily life by Paul W. Frields
 
Autotitles in screen.

Autotitles in screen.

This comes in really handy in ~/.screenrc:

shelltitle '$ |bash'

Then add this in ~/.bashrc:

export PROMPT_COMMAND='[ "$TERM" == "screen" ] && echo -n -e "\033k\033\\\"'

Restart screen in a fresh bash session and enjoy.

UPDATE: I stupidly screwed up the screenrc line because I did it from memory instead of copypasta. No cookie for me!

UPDATE #2: Aha, found that something in the innards of my blog software was removing an extra backslash that was needed in the export command above. Sorry for the mess.

8 Comments

  1. Stephen Smoogen

    You broke my screen :). I don’t know what happened by the screen just sits there forever. Though I think it said something about unknwon command the first time.

    EL-6

  2. What does it do really? Will it work with byobu? /me is getting an error too:

    bash: PROMPT_COMMAND: line 0: unexpected EOF while looking for matching `”‘
    bash: PROMPT_COMMAND: line 1: syntax error: unexpected end of file

    🙂

  3. Heya Paul,

    I use the venerable ‘screen’ on RHEL systems in day-to-day life. But on my Fedora laptop, lately I started using ‘tmux'(I’m sure you must have heard of it) and I’ve been very happy with it.

    A few things which I really liked:
    – Splitting(horizontally/vertically) a screen into panes is extremely handy and simple. (in ‘screen’ the splits are lost if we re-attach)
    – Very ‘readable’ (and less cryptic) conf file
    – Sharing an interactive session w/ a remote person is also very trivial (it’s possible w/ ‘screen’ too )

    I posted my ‘tmux’ config here – if you care 🙂
    //github.com/kashyapc/config-files/blob/master/tmux.conf

    Not trying to convert you or something, just nothing it here, as you’re a super-power user

    NOTE: The key bindings by default are CTL+B. But, it’s very trivial to change it to CTL+A . My config file above has the key-binding as CTL+A as that’s what I’ve been used to with ‘screen’ 🙂

  4. Tim Niemueller

    Does not work for me, blank screen and sits there, using the already updated version. The prompt command escapes the last quote. I assume you wanted “\\”?. But then it shows only “screen” in the terminal tab instead of the prompt. Maybe you can describe the expected effect briefly?

  5. mmmmmm bash working oddly around here

    ]0;export PROMPT_COMMAND='[ “$TERM” == “screen” ] && echo -n -e “k”‘bash: PROMPT_COMMAND: line 0: unexpected EOF while looking for matching `”‘
    bash: PROMPT_COMMAND: line 1: syntax error: unexpected end of file

  6. @Tim: That was the problem — something in my blog was removing the second backslash. What you should see when the feature works is that the titles of your screen windows will automatically change to the program you’re running there. This is really useful when you tend to run Mutt, irssi, offlineimap, $EDITOR, etc. in those windows.

  7. Pingback: The Grand Fallacy » Finding old test packages in Koji.

Comments are closed.