2 votesby stackoverflow.com/users/2450431written 2017-04-23last updated 2017-04-23
I would like to suggest an alternative solution that is always visible and does not require checking to know you are inside a screen session.
Just add/edit a file ~/.screenrc in your $HOME folder and add caption command:
caption always "%{= kc}Screen session on %H (system load: %l)%-28=%{= .m} %Y-%m-%d %0c"
and you will get at the very bottom one line that is always visible and colored.
Screen session on host (system load: 1.50 1.40 1.30) 2017-04-23 14:06
Please note:
When you are inside screen on host1 and open another SSH session to host2 and open screen there which also has .screenrc you will get two lines at the bottom stacked from bottom up (like a wrapper).
This is VERY useful in that case!
Screen session on host2 (system load: 0.01 0.03 0.05) 2017-04-23 14:14
Screen session on host1 (system load: 0.00 0.00 0.00) 2017-04-23 14:14
Additional info:
https://www.gnu.org/software/screen/manual/html_node/Caption.html
Command: caption always|splitonly [string]
https://www.gnu.org/software/screen/manual/html_node/String-Escapes.html#String-Escapes
I found this hit here on SO.