将较小的监视器切换到较大的监视器时,有没有办法重绘 tmux 窗口? [英] Is there any way to redraw tmux window when switching smaller monitor to bigger one?

查看:73
本文介绍了将较小的监视器切换到较大的监视器时,有没有办法重绘 tmux 窗口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设您使用 Terminal.app 通过 ssh 连接到远程服务器.当您从之前启动 tmux 的较小显示器tmux attach"到更大分辨率的显示器时,它会在控制台周围绘制点.它不适合新的窗口大小.有没有办法重新绘制和清洁窗口?CTRL+LCTRL-B + R 没有帮助.我在 man 上找不到任何正确的命令.

Let's say you're connecting to a remote server over ssh with Terminal.app. When you "tmux attach" with bigger resolution monitor from smaller one you previously started tmux, it draws dots around the console. It doesn't fit the new window size. Is there any way to redraw and clean the window? CTRL+L or CTRL-B + R doesn't help. I couldn't find any proper command on man.

% tmux -V
tmux 1.5

推荐答案

tmux 将窗口的尺寸限制为窗口附加到的所有会话中每个尺寸的最小尺寸.如果不这样做,就没有明智的方法来显示所有附加客户端的整个窗口区域.

tmux limits the dimensions of a window to the smallest of each dimension across all the sessions to which the window is attached. If it did not do this there would be no sensible way to display the whole window area for all the attached clients.

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

The easiest thing to do is to detach any other clients from the sessions when you attach:

tmux attach -d

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

Alternately, you can move any other clients to a different session before attaching to the session:

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

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

The screen will shrink again if a smaller client switches to the session.

还有一种变体,您只需接管"窗口(将窗口链接到一个新会话,设置 aggressive-resize,并将该窗口处于活动状态的任何其他会话切换到某些其他窗口),但在一般情况下更难编写脚本(与退出"不同,因为您希望取消链接窗口或终止会话,而不仅仅是从会话中分离).

There is also a variation where you only "take over" the window (link the window into a new session, set aggressive-resize, and switch any other sessions that have that window active to some other window), but it is harder to script in the general case (and different to "exit" since you would want to unlink the window or kill the session instead of just detaching from the session).

这篇关于将较小的监视器切换到较大的监视器时,有没有办法重绘 tmux 窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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