• Esse quam videri.

  • Archives

  • Control Room

  • Categories

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.


  1. Stephen Smoogen said,

    March 3, 2012 @ 2:28 pm

    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.


  2. Paul said,

    March 3, 2012 @ 3:38 pm

    @Smooge: Sorry about that — I remembered the command wrong. The updated recipe should give you the full-on goodness I first intended. :-)

  3. FranciscoD said,

    March 4, 2012 @ 2:16 am

    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


  4. Kashyap Chamarthy said,

    March 4, 2012 @ 6:01 am

    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 :) https://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’ :)

  5. Tim Niemueller said,

    March 4, 2012 @ 8:14 am

    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?

  6. Carlos (casep) Sepulveda said,

    March 4, 2012 @ 5:14 pm

    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

  7. Paul said,

    March 5, 2012 @ 7:07 am

    @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.

  8. The Grand Fallacy » Finding old test packages in Koji. said,

    March 13, 2012 @ 6:28 am

    […] commit of interest in starts with “0123abcd” (and let’s hope I do better than in the last post in which I gave […]

RSS feed for comments on this post

© 2002-2015 Paul W. Frields License: CC BY-SA 3.0. Some rights reserved. -- Copyright notice by Blog Copyright

%d bloggers like this: