Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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 have this in my .screenrc

caption always "%{= Kw} [%0c] %-Lw%{= KW}[%50>%n%f* %t]%{= Kw}%+Lw%=| %l | ${FULLHOST}"

It normally displays something like this:

[01:06] 0$ vim  1$ top  2-$ tail  [3$* ~]          | 0.26 0.54 0.36 |

However, when I have lots of windows open, the data on the right is pushed off the edge and truncated:

[01:07] 0$ vim  1$ top  2$ tail  3$ ~  4$ ~  5$ ~  6-$ ~  [7$* ~] | 0.21 0.46 0.34 | mac

How can I change the caption command so it will truncate the window list if neccessary, rather than pushing the right information off the edge? Bonus points if the active window is always displayed too.

share|improve this question
up vote 4 down vote accepted

Another solution, that I'm currently using. Instead of '%=' as in the original line, or '%-30=' in bender's (which aligns to the -30% (aka 70%) mark), I'm using '%-043=' (which aligns to the -43 character mark). But of course this has the same problem as bender's, where the amount I need to offset changes for each server. The solution is to edit the .screenrc per-server, with a command like this:

sed -i "s/043/0$(( 19 + $#FULLHOST ))/" ~/.screenrc

(The 19 is the number of characters used by the load display and spacing)

Since my .screenrc is generated by my shell's .rc file if it's not there, I can immediately run this command after doing so and end up with a correctly offset alignment for each server. Not elegant, but it works!

Remaining problems, that I don't really care about enough to solve:

  • The window list (and anything to the left, including the time) gets pushed off the left now. I solved this by removing the clock.
  • If the hostname of the machine changes, I need to regenerate the .screenrc, which involves deleting it and then starting a new shell.
share|improve this answer

I use:

caption always "%-Lw%{= Yk}%50>%n%f*%t%{-}%+Lw%<%-12= %?%F%?%{b}%c %m/%d%?"

This displays something like:

0*bender@armitage  1 bender@rikki  2 bender@gibson     15:11 05/30

This keeps the time and date on the status line and the active window in the list as the window list size grows. The magic bit you're missing is a defined width for the part that you want to keep on the right hand side. This is the "%-12=" width directive in my caption command.

Try something like:

caption always "%{= Kw} [%0c] %-Lw%{= KW}[%50>%n%f* %t]%{= Kw}%+Lw%-30=| %l | ${FULLHOST}"

You'll need to play with the width (%-30= above) to get your complete hostname to display.

share|improve this answer
This half works. The catch is that I want to use this caption unmodified across a whole bunch of servers, which means I can't just pick an arbitrary width. – Alex J May 31 '09 at 3:51

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.