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

3

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 I used to create the current screen session.

However, I cannot seem to accomplish this. Any ideas?

Neg_EV

Posted 2010-03-19T16:06:27.160

Reputation: 575

Answers

1

This is coming in the next version: http://savannah.gnu.org/bugs/index.php?23738

Also, you can use the terminal variable $STY, though people seem to get inconsistent results with it.

Max Cantor

Posted 2010-03-19T16:06:27.160

Reputation: 436

0

This was successfully emulated by how to include screen's session name in hardstatus?

I enhanced it even further, as follows:

# generates equivalent of $STY followed by "on $HOST" if $STY is non-standard
backtick 10 60 60 sh -c 'sty=$(screen -ls | grep --color=no -o "$PPID[^[:space:]]*") ; if [ ${sty##*.} = $HOST ] ; then echo $sty ; else echo "$sty on $HOST" ; fi'
# includes session name thanks to backtick 10
hardstatus string "[screen %n%?: %t%? (%10`)] %h"

Alastair Irvine

Posted 2010-03-19T16:06:27.160

Reputation: 278

0

Max Cantor refers to a next version in his answer. Now it easily works with %S in 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).

Scz

Posted 2010-03-19T16:06:27.160

Reputation: 263