我遇到了一个奇怪的困境。我想在 ssh 连接的远程端检测客户端是否在屏幕会话内运行终端。我想根据此设置我的提示。到目前为止,我尝试使用remotehost:~/.ssh/env
[1] 和SendEnv
我的选项
localhost:~/.ssh/config
发送我的$STY
变量 [2];但都失败了。
所以我想知道是否还有其他方法可以实现这一点?
脚注:
[1] 这不起作用,因为它没有评估任何东西,我无法动态地设置。
[2] 这需要AcceptEnv
在远程端允许。这是不可能的,因为我不是远程主机的管理员,即使我是,也不建议man sshd_config
这么做。
答案1
尝试这个:
if [ "${TERM}" == "screen" ]
then
# Set prompt to something special for screen.
fi
以下是来自屏幕手册页:
term term
In each window's environment screen opens, the $TERM variable is set to "screen" by default. But when no description for "screen" is installed in the
local termcap or terminfo data base, you set $TERM to - say - "vt100". This won't do much harm, as screen is VT100/ANSI compatible. The use of the "term"
command is discouraged for non-default purpose. That is, one may want to specify special $TERM settings (e.g. vt100) for the next "screen rlogin otherma-
chine" command. Use the command "screen -T vt100 rlogin othermachine" rather than setting and resetting the default.