如何显示当前的“会话"名称或“袜子名称";状态栏中的屏幕会话? [英] How do I display the current "session" name or "sockname" of a screen session in the status bar?

查看:50
本文介绍了如何显示当前的“会话"名称或“袜子名称";状态栏中的屏幕会话?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我运行多个屏幕会话,每个会话都使用'screen -S 名称 创建,并且我希望能够在状态栏中显示 名称 我曾经创建当前的屏幕会话.

I run multiple screen sessions each created with 'screen -S name' and I would like to be able to display in the status bar the name I used to create the current screen session.

但是,我似乎无法做到这一点.有什么想法吗?

However, I cannot seem to accomplish this. Any ideas?

推荐答案

screen有两个状态栏,标题栏和hardstatus栏,它们都使用主屏幕.不幸的是,没有转义直接指向会话名称.

screen has two status bars, the caption bar and the hardstatus bar, both of which use the string escapes specified in the "STRING ESCAPES" section of man screen. Unfortunately, there is no escape that directly refers to the session name.

但是,有一种黑客可以让您做到这一点.

However, there is a hack that will allow you to do this.

screen使用$STY变量将会话名称传递给Shell.当外壳程序尝试设置窗口标题时(使用其中一种方法)screen捕获了该尝试,并将其存储在一个令人困惑的"window hardstatus"中,该确有一个转义符,您可以使用:%h.

screen passes the session name to the shell using the $STY variable. When the shell attempt to set the window title (using one of these methods) screen captures that attempt, and stores it in something it confusingly calls "the window hardstatus," which does have an escape that you can use: %h.

因此,如果您将标题栏或hardstatus栏设置为包含%h,并且外壳程序尝试将窗口标题设置为$STY,则当该栏为%h时,%h将替换为会话名称.显示.

So if you have either the caption or hardstatus bar set to include %h and have the shell attempt to set the window title to $STY, then the %h will be replaced with the session name when the bar is displayed.

这篇关于如何显示当前的“会话"名称或“袜子名称";状态栏中的屏幕会话?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆