使用 GNU 屏幕作为登录“shell”

wfa*_*ulk 23 unix shell login gnu-screen

打开新 shell 时让 screen 自动运行的最佳方法是什么,无论是通过登录、xterm 还是其他任何方式?

我看到最常见的建议是放入exec screen常规 shell 的 rc 或登录/配置文件,但对于例如 tcsh,登录 shell 最后运行 .login,而非登录 shell 最后读取 .cshrc。如果我放入exec screen.cshrc,登录 shell 将不会获取 .login 文件,如果我将它放入 .login,非登录 shell 将不会运行 screen。我认为其他 shell 也存在类似的问题。

use*_*686 20

一种方法是:

# if $STY is not set...
if [ -z "$STY" ]; then
    exec screen -ARR
fi
Run Code Online (Sandbox Code Playgroud)

请注意,这是为 编写的bash,但也应该与 相似csh。将其设置.cshrc为对所有shell执行。


另一种方法:你可以简单地设置screen为登录shell/etc/passwd本身,并把此行到您的~/.screenrc:(当然固定的路径。)

defshell /bin/csh

但这可能会破坏运行/etc/passwd为各种命令定义的登录 shell 的程序。

编辑:不要忘记添加屏幕/etc/shells