How to tell whether the shell is run in screen

How to tell whether the shell is run in screen? For example, I run screen and it starts a bash environment. How to tell in the bash, whether it is run by screen or it is a normal bash environment?

asked Oct 28, 2013 by anonymous

1 Answer

Best answer

It can be identified by checking the TERM environment variable:

In a bash in screen:

[zma@localhost ~]$ env | grep TERM
TERMCAP=SC|screen|VT 100/ANSI X3.64 virtual terminal:\

However, in a "normal" bash environment:

[zma@localhost ~]$ env | grep TERM

"In each window's environment screen opens, the $TERM variable is set to "screen" by default." -- screen manual

answered Oct 28, 2013 by anonymous
How to add a "status bar" to screen on Linux? asked Nov 18, 2014 by Eric Z Ma (44,280 points)

Please log in or register to answer this question.

Copyright © SysTutorials. User contributions licensed under cc-wiki with attribution required.
Hosted on Dreamhost