I am using GNU screen with a horizontal split, but it is not always easy to decide which pane is active (e.g. when using a program like top in one of the panes). Is it possible to change the color of the text in the caption, when the pane is active?

I use these settings right now:

hardstatus alwayslastline "%{= G}%{g}[ %{G}%H %{g}][ %?%-Lw%?%{R} %n*%f %t %{g}%?%+Lw%? %{g}]%=%{g}[ %{W}%c:%s %{g}]"
caption splitonly "%{= g}[%n %t]"

It would be nice to be able to change the color of %n %t to R when the pane is active, or some other way of highlighting the pane.


I looked at the STRING ESCAPES section of the screen man page and found what you may be after. The ? escape is like an if statement and the : escape is like an else statement. The F escape is true when that window has the focus. So the if-then-else statement for the if active then, else would look like this (padding added for readability):

%? %F active-window options %: inactive-window-options %?

The original option was %{= g} (pad string to display width and green) changing the active screen text to bright red will look like this:

caption splitonly "%?%F%{= R}%:%{= g}%?[%n %t]"


  • 2
    Welcome to Unix & Linux!  We’re looking for substantial answers that provide some explanation and context.  Please don’t give just a couple of lines of code; explain why your answer is right, ideally with citations.  Answers that don’t include explanations may be removed. – G-Man Nov 1 '15 at 6:30
  • @G-Man He basically solved the problem for though, even if it is not all that well written. – fbence Nov 4 '15 at 21:36
  • @Lee thanks for the input, this solves the issue, I've tidied up the answer a bit. – fbence Nov 4 '15 at 21:47
  • @fbence: But did you see the first version of the answer, which is the one I commented on? – G-Man Nov 5 '15 at 8:08
  • @G-Man Hmm, I only saw the version I edited, and didn't see any indication that is was edited, although I'm not a real pro around here so there might have been :) Anyway, I think it is okay now, with my edit. – fbence Nov 5 '15 at 10:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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