How do I display the current “session” name or “sockname” of a screen session in the status bar?

后端 未结 7 1404
醉酒成梦
醉酒成梦 2020-12-13 04:15

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

相关标签:
7条回答
  • 2020-12-13 04:46

    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.

    0 讨论(0)
  • 2020-12-13 04:47

    The easiest way to display the sessionname is

      C-a : 
      sessionname
    

    (without specifying a name after sessionname)

    See the "CUSTOMIZATION" section in man screen

    0 讨论(0)
  • 2020-12-13 04:51

    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).

    0 讨论(0)
  • 2020-12-13 04:58

    paraphrased from https://superuser.com/a/212520/151988, put this into your ~/.screenrc;

    screen 
    screen $SHELL -c 'screen -X caption always "$STY"'
    
    0 讨论(0)
  • 2020-12-13 05:07

    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"
    
    0 讨论(0)
  • 2020-12-13 05:09

    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

    0 讨论(0)
提交回复
热议问题