Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm looking for a way to get the current window title in GNU screen .
I have a script that use screen -X title something to change the window title when running and I would like to set it back to it's previous value at the end of the script.

share|improve this question
@ radius - I'd put the OS you are doing this in on here. In Windows you'd typically call a Win32 function in AutoHotKey to do this. – J. Polfer Jul 17 '09 at 13:54
I'm talking about GNU Screen not screen like a monitor. – radius Jul 17 '09 at 14:01
I've had a bit of a look around the web, and it looks like the answer is "you can't do that, but it might get added in a future version". See thread starting at – Zanchey Jul 17 '09 at 14:58

"screen -X" attach a command to a specified screen session, it has no effect on the window title. Either your script uses an escape sequence to set the screen window title, or your screenrc does. Take notice that screen windows are unrelated to terminal (xterm, etc) windows.

share|improve this answer
Try "screen -X title foobar" in a screen window and you will see that it does change it's name like when you do crtl-a-A – radius Jul 17 '09 at 14:41
That's true, I didn't know that :) – wazoox Jul 17 '09 at 16:10

You can take a look at two of my blog posts regarding using zsh kludges to make this work,

I use a combination of factors to do it, primarily a preexec() hook in my shell, which can just as easily work with another shell.

I believe that the code in the post may be outdated, the relevant files are always up to date here:

If you're a vim user, you'll almost certainly want to set titleold to something meaningful as well to avoid your title getting clobbered on exit.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.