如何判断我是否在屏幕上? [英] How can I tell whether I'm in a screen?
本文介绍了如何判断我是否在屏幕上?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在Linux中使用屏幕时,如何确定我是否在屏幕中?
我可以执行exit
,如果我在其中,我将退出一个屏幕,但是如果不是,我将最终关闭我的终端.
When using screen in linux, how can I tell if I'm in a screen or not?
I could do exit
and I'll exit a screen if I was in one, but if I wasn't, then I'll end up closing my terminal.
执行screen -r
时,我可以查看是否还连接了其他屏幕,但是如何知道我的当前终端是否是这些已连接屏幕之一?
When doing screen -r
, I could see if I have other screens attached, but how do I know if my current terminal is one of those attached screens?
推荐答案
选中$STY
.如果为空,则您位于真实"终端上.如果其中包含任何内容,则为您所在屏幕的名称.
Check $STY
. If it's null, you're on a "real" terminal. If it contains anything, it's the name of the screen you're in.
如果您不在屏幕上:
eric@dev ~ $ echo $STY
eric@dev ~ $
如果您在屏幕上:
eric@dev ~ $ echo $STY
2026.pts-0.ip-10-0-1-71
这篇关于如何判断我是否在屏幕上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文