我在一个较小的终端上启动了一个tmux会话。当我在一个更大分辨率的监视器上“附加”到同一个会话时,它会在控制台周围画点。它不适合新的窗口大小。有没有办法重画并擦干净窗户?CTRL+L或CTRL- b + R没有帮助。


当前回答

Tmux将窗口的维度限制为窗口所连接的所有会话的每个维度中最小的维度。如果不这样做,就没有合理的方法来显示所有附加客户端的整个窗口区域。

最简单的方法就是在附加时从会话中分离任何其他客户端:

tmux attach -d

或者,你可以在附加到会话之前将任何其他客户端移动到不同的会话:

takeover() {
    # create a temporary session that displays the "how to go back" message
    tmp='takeover temp session'
    if ! tmux has-session -t "$tmp"; then
        tmux new-session -d -s "$tmp"
        tmux set-option -t "$tmp" set-remain-on-exit on
        tmux new-window -kt "$tmp":0 \
            'echo "Use Prefix + L (i.e. ^B L) to return to session."'
    fi

    # switch any clients attached to the target session to the temp session
    session="$1"
    for client in $(tmux list-clients -t "$session" | cut -f 1 -d :); do
        tmux switch-client -c "$client" -t "$tmp"
    done

    # attach to the target session
    tmux attach -t "$session"
}
takeover 'original session' # or the session number if you do not name sessions

如果一个较小的客户端切换到会话,屏幕将再次缩小。

还有一种变化是,您只“接管”窗口(将窗口链接到一个新的会话,设置主动调整大小,并将任何其他会话将该窗口活动到其他窗口),但在一般情况下,它更难以脚本化(与“退出”不同,因为您想要解除窗口链接或终止会话,而不仅仅是从会话分离)。

其他回答

Tmux将窗口的维度限制为窗口所连接的所有会话的每个维度中最小的维度。如果不这样做,就没有合理的方法来显示所有附加客户端的整个窗口区域。

最简单的方法就是在附加时从会话中分离任何其他客户端:

tmux attach -d

或者,你可以在附加到会话之前将任何其他客户端移动到不同的会话:

takeover() {
    # create a temporary session that displays the "how to go back" message
    tmp='takeover temp session'
    if ! tmux has-session -t "$tmp"; then
        tmux new-session -d -s "$tmp"
        tmux set-option -t "$tmp" set-remain-on-exit on
        tmux new-window -kt "$tmp":0 \
            'echo "Use Prefix + L (i.e. ^B L) to return to session."'
    fi

    # switch any clients attached to the target session to the temp session
    session="$1"
    for client in $(tmux list-clients -t "$session" | cut -f 1 -d :); do
        tmux switch-client -c "$client" -t "$tmp"
    done

    # attach to the target session
    tmux attach -t "$session"
}
takeover 'original session' # or the session number if you do not name sessions

如果一个较小的客户端切换到会话,屏幕将再次缩小。

还有一种变化是,您只“接管”窗口(将窗口链接到一个新的会话,设置主动调整大小,并将任何其他会话将该窗口活动到其他窗口),但在一般情况下,它更难以脚本化(与“退出”不同,因为您想要解除窗口链接或终止会话,而不仅仅是从会话分离)。

您可以使用<Ctrl-B>: + at -d <CR>重绘tmux窗口。

在最近版本的tmux上有一个更简单的解决方案(在1.9上测试),你现在可以这样做:

tmux detach -a

-a用于会话中除当前客户端以外的所有其他客户端

你可以在你的。[bash|zsh]rc中使用别名

alias takeover="tmux detach -a"

工作流:您可以正常连接到您的会话,如果您被另一个会话强制降低您的tmux窗口大小所困扰,您可以简单地调用接管。

我使用Ctrl-b + q,这使得它闪光的数字为每个窗格,重新绘制他们的方式。

您总是可以按CTRL-B + SHIFT-D来选择要从会话中分离的客户端。

Tmux将列出所有会话及其当前维度。然后只需从所有较小的会话中分离。