“屏幕”的隐藏功能

Jos*_*osh 31 gnu-screen

由于我整天都在使用*nix 命令screen,并且找不到任何人提出这个问题,我认为应该开始。你知道练习:社区维基,每个功能一个答案,所以我们都可以投票。

Sco*_*ack 31

喜欢用它来连接串行控制台,即

screen /dev/ttyS0 19200
Run Code Online (Sandbox Code Playgroud)

此命令只是以 19200 的波特率打开与串行端口 0 (ttyS0) 的连接


KTa*_*mas 10

最好的功能screen是 Byobu(以前的屏幕配置文件),它自 Jaunty 以来默认随 Ubuntu 一起提供:https : //launchpad.net/byobu

这是一个配置管理器,具有非常好的默认值、大量状态通知和有用的键盘快捷键(即 f2 用于新屏幕,f3-f4 用于上一个/下一个等)

没有它我真的不会去任何地方了:)


Jos*_*osh 10

来自 KTamas 的回答: 可以多人使用同一个屏幕,即如果你的一个朋友ssh进入你的电脑,那么他就可以连接到你的屏幕。当两三个人在同一个项目上工作时,这很棒。


小智 6

不完全是“隐藏功能”;但是正确设置的 .screenrc 文件可以带来不同的世界。可以通过谷歌搜索 screenrc 和 'brad sims' 找到一个更好的例子 - 他有一个很好的文件可以修改。

也就是说,我最喜欢的设置是 bindkey:

# bind F7  to detach screen session from this terminal
# bind F8  to kill current screen window.
# bind F9  to create a new screen
# bind F10 to rename current screen window
# bind F11 to move to previous window
# bind F12 to move to next window
bindkey -k k7 detach
bindkey -k k8 kill
bindkey -k k9 screen
bindkey -k k; title
bindkey -k F1 prev
bindkey -k F2 next
Run Code Online (Sandbox Code Playgroud)

  • 考虑到 ctrl+a 经常在屏幕外使用(bash 中的行首?)我喜欢这个。 (2认同)

z0m*_*bix 6

我不记得我从谁那里偷了这个(dotfile.org 上的某个人)。我已经为 ssh 稍微修改了它:

#!/bin/sh
# scr - Runs a command in a fresh screen
#
# Get the current directory and the name of command

wd=`pwd`
cmd=$1
shift

# We can tell if we are running inside screen by looking
# for the STY environment variable.  If it is not set we
# only need to run the command, but if it is set then
# we need to use screen.

if [ -z "$STY" ]; then
        $cmd $*
else
        # Screen needs to change directory so that
        # relative file names are resolved correctly.
        screen -X chdir $wd

        # Ask screen to run the command
        if [ $cmd == "ssh" ]; then
                screen -X screen -t ""${1##*@}"" $cmd $*
        else
                screen -X screen -t "$cmd $*" $cmd $*
        fi
fi
Run Code Online (Sandbox Code Playgroud)

然后我设置了以下 bash 别名:

vim() {
        scr vim $*
}

man() {
        scr man $*
}

info() {
        scr info $*
}

watch() {
        scr watch $*
}

ssh() {
        scr ssh $*
}
Run Code Online (Sandbox Code Playgroud)

它为上述别名打开一个新屏幕,如果使用 ssh,它会使用 ssh 主机名重命名屏幕标题。

干杯 z0mbix