I run multiple screen sessions each created with \'screen -S name\' and I would like to be able to display in the status bar the name
As max_cantor says in the SuperUser Answer, an escape character for the session name should be added to version 4.1.0. It looks like the escape character function was added with a relatively small patch back in 2008. So if you're feeling brave, you can git yourself a copy of the development version 4.1.0 and try it out.
I'll try this with the development version when I get a chance.
The easiest way to display the sessionname is
C-a :
sessionname
(without specifying a name after sessionname
)
See the "CUSTOMIZATION" section in man screen
In current versions of screen
, there is a flag %S
for the hardstatus line.
MWE (.screenrc):
hardstatus on
hardstatus alwayslastline
hardstatus string "%S"
This displays the session name without the ID (like ${STY#*.}
).
(Same answer to other questions here and here for completeness).
paraphrased from https://superuser.com/a/212520/151988, put this into your ~/.screenrc;
screen
screen $SHELL -c 'screen -X caption always "$STY"'
If nothing else works (as for me), as a workaround you can create a window with number 0 and set title to your screen name:
screen -S myscreen
C^a :title "myscreen"
Super User has an answer to this that does not require $STY
, instead using the backtick
screen config command and screen -ls
: https://superuser.com/a/212520