Understanding GNU Screen’s hardstatus strings

My cur­rent devel­op­ment set­up revolves main­ly around Vim and GNU Screen. I use Screen only to keep ses­sions run­ning between work days or in case I get dis­con­nect­ed, but late­ly I’ve been tempt­ed to try using dif­fer­ent win­dows inside Screen. In order to make this eas­i­er, I want­ed one of those sta­tus lines that shows you all your win­dows as “tabs”.

Con­fig­ur­ing this sta­tus line (the “hard­ware sta­tus line” or, as I’ll call it, “hard­sta­tus”) is done with a sin­gle, often long string of char­ac­ters in ~/.screenrc that at first can look entire­ly baf­fling:

hardstatus string "%{= KW} %H [%`] %{= Kw}|%{-} %-Lw%{= bW}%n%f %t%{-}%+Lw %=%C%a %Y-%M-%d"


To my dis­may, almost every­thing I can find about hard­sta­tus through Google are just dumps of oth­er people’s strings, with lit­tle to no expla­na­tion about why they do what they do – it’s easy to imag­ine that the peo­ple who post them hard­ly know why they do what they do, either. GNU’s offi­cial doc­u­men­ta­tion isn’t ter­ri­bly help­ful.

After final­ly deci­pher­ing a lot of what goes on in these strings, I want­ed to spell it out to any­body else who might be hunt­ing around for half a clue about this voodoo. There are (more than?) a few things I haven’t cov­ered here, of course – trun­ca­tion and con­di­tion­als, name­ly – but this should be enough to get you start­ed.

Con­tin­ue →