How can I add the session name to my screen status display?

This is my current .screenrc files which is mostly copied from the link in the code

#First iteration 2014-09-06, not quite sure of stuff to add
# got a fancy hardstatus line noted below
hardstatus on
hardstatus alwayslastline
# hardstatus string "%w"

# blagged this hardstatus like from https://bbs.archlinux.org/viewtopic.php?id=55618, not quite sure what it does
hardstatus string '%{= kG}%{C}Screen: %{c}%{= kG}[%= %{= kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{C} %d-%m %{W}%c %{g}]'

I now want the session name to appear in it as well, and the one I have settled on is from this answer – https://superuser.com/questions/212392/how-to-include-screens-session-name-in-hardstatus/212520#212520

The solution runs along these line:

hardstatus string '%H:%`'
backtick 0 30 30 sh -c 'screen -ls | grep --color=no -o "$PPID[^[:space:]]*"'

It is an area I am not familiar with and I wonder how the backtick command fits in it, ie whether it is a screen command at all.

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

You can check this or better you can check man page for screen which is a good reference and says:

backtick id lifespan autorefresh cmd args…
backtick id

Program the backtick command with the numerical id id. The output of such a command is used for substitution of the “%`” string escape. The specified lifespan is the number of seconds the output is considered valid. After
this time, the command is run again if a corresponding string escape is encountered. The autorefresh parameter triggers an automatic refresh for caption and hardstatus strings after the specified number of seconds. Only
the last line of output is used for substitution.
If both the lifespan and the autorefresh parameters are zero, the backtick program is expected to stay in the background and generate output once in a while. In this case, the command is executed right away and screen
stores the last line of output. If a new line gets printed screen will automatically refresh the hardstatus or the captions.
The second form of the command deletes the backtick command with the numerical id id.

As per your example you can add:

hardstatus string '%H:%1` | %2`'
backtick 1 30 30 sh -c 'screen -ls | grep --color=no -o "$PPID[^[:space:]]*"'
backtick 2 60 60 /usr/bin/uptime


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x