Linux 如何为屏幕指定名称?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3202111/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to assign name for a screen?
提问by spankmaster79
I'm using the screen
multiplexer tool on the command shell and open a lot of screens. I then forget which process ID associates with which task.
我screen
在命令外壳上使用多路复用器工具并打开很多屏幕。然后我忘记了哪个进程 ID 与哪个任务相关联。
I would like to set a name for a screen but can't find an option in the manpage.
我想为屏幕设置名称,但在联机帮助页中找不到选项。
Currently, listing the screens looks like this:
目前,列出屏幕如下所示:
There are screens on:
5422.pts-1.aws1 (Detached)
5448.pts-1.aws1 (Detached)
5027.pts-1.aws1 (Detached)
3 Sockets in /var/run/screen/S-sb.
And I would like to see something like this:
我想看到这样的事情:
There are screens on:
5422.logCleanWorker (Detached)
5448.overNightLongTask(Detached)
5027.databaseOverNightLongTask (Detached)
3 Sockets in /var/run/screen/S-sb.
How can I do this?
我怎样才能做到这一点?
采纳答案by user164176
To start a new session
开始新的会话
screen -S your_session_name
screen -S your_session_name
To rename an existing session
重命名现有会话
Ctrl+a, :sessionname YOUR_SESSION_NAME Enter
Ctrl+ a,:会话名称 YOUR_SESSION_NAMEEnter
You must be inside the session
您必须在会话中
回答by miedwar
To create a new screen with the name foo
, use
要foo
使用名称创建新屏幕,请使用
screen -S foo
Then to reattach it, run
然后重新连接它,运行
screen -r foo # or use -x, as in
screen -x foo # for "Multi display mode" (see the man page)
回答by Saurabh Hirani
I am a beginner to screen but I find it immensely useful while restoring lost connections. Your question has already been answered but this information might serve as an add on - I use putty with putty connection manager and name my screens - "tab1", "tab2", etc. - as for me the overall picture of the 8-10 tabs is more important than each individual tab name. I use the 8th tab for connecting to db, the 7th for viewing logs, etc. So when I want to reattach my screens I have written a simple wrapper which says:
我是筛选的初学者,但我发现它在恢复丢失的连接时非常有用。您的问题已得到解答,但此信息可能会作为附加信息 - 我将 Putty 与 Putty 连接管理器一起使用并命名我的屏幕 - “tab1”、“tab2”等 - 至于我 8-10 的整体情况tabs 比每个单独的选项卡名称更重要。我使用第 8 个选项卡连接到 db,第 7 个选项卡用于查看日志等。因此,当我想重新连接屏幕时,我编写了一个简单的包装器,上面写着:
#!/bin/bash
screen -d -r tab
where first argument is the tab number.
其中第一个参数是制表符编号。
回答by OneOFPunx
The easiest way use screen with name
使用带有名称的屏幕的最简单方法
screen -S 'name' 'application'
- Ctrl+a, d= exit and leave application open
- Ctrl+ a, d= 退出并让应用程序保持打开状态
Return to screen:
返回画面:
screen -r 'name'
for example using lynx with screen
例如使用带有屏幕的lynx
Create screen:
创建画面:
screen -S lynx lynx
Ctrl+a, d=exit
Ctrl+ a, d= 退出
later you can return with:
稍后您可以返回:
screen -r lynx
回答by E4Y
As already stated, screen -S SESSIONTITLE
works for starting a session with a title (SESSIONTITLE
), but if you start a session and later decide to change its title. This can be accomplished by using the default key bindings:
如前所述,screen -S SESSIONTITLE
适用于以标题 ( SESSIONTITLE
) 开始会话,但如果您开始会话并稍后决定更改其标题。这可以通过使用默认键绑定来完成:
Ctrl+a, A
Ctrl+ a,A
Which prompts:
其中提示:
Set windows title to:SESSIONTITLE
Change SESSIONTITLE
by backspacing and typing in the desired title. To confirm the name change and list all titles.
SESSIONTITLE
通过退格和键入所需的标题进行更改。确认名称更改并列出所有标题。
Ctrl+a, "
Ctrl+ a,"