tmux和terminal终端使用笔记

tmux设置状态栏的背景:

set-option -g status-style bg=blue

设置当前使用的panel标签背景:

set-window-option -g window-status-current-bg red

设置前景字体显示

set -g status-style "fg=green,bold,noreverse"
set -g status-justify centre
set -g status-right ""
set -g status-left ""
set-window-option -g mode-keys vi

设置当前window的状态栏前景字体显示

set-window-option -g window-status-current-style "reverse,bold,bright"
set-option -s set-clipboard off
bind-key j setw synchronize-panes
bind-key h setw status

终端快捷键:

ctrl-s, 冻结客户端的终端输出, 客户端输入仍然会发送到ssh服务端
ctrl-q, 解冻客户端的终端输出, 之前冻结的输出也会陆续输出到屏幕
ctrl-b s, 查看所有windows的缩略图,并且可以用上下左右键以及enter键选中某一个windows
ctrl-b j, 向当前window的所有panel同步输入(或取消同步输入)

官方文档中的快捷键说明:

KEY BINDINGS
     tmux may be controlled from an attached client by using a key combination of a prefix key, ‘C-b’ (Ctrl-b) by default, followed by a command key.

     The default command key bindings are:

           C-b         Send the prefix key (C-b) through to the application.
           C-o         Rotate the panes in the current window forwards.
           C-z         Suspend the tmux client.
           !           Break the current pane out of the window.
           "           Split the current pane into two, top and bottom.
           #           List all paste buffers.
           $           Rename the current session.
           %           Split the current pane into two, left and right.
           &           Kill the current window.
           ’           Prompt for a window index to select.
           ,           Rename the current window.
           -           Delete the most recently copied buffer of text.
           .           Prompt for an index to move the current window.
           0 to 9      Select windows 0 to 9.
           :           Enter the tmux command prompt.
           ;           Move to the previously active pane.
           =           Choose which buffer to paste interactively from a list.
           ?           List all key bindings.
           D           Choose a client to detach.
           [           Enter copy mode to copy text or view the history.
           ]           Paste the most recently copied buffer of text.
           c           Create a new window.
           d           Detach the current client.
           f           Prompt to search for text in open windows.
           i           Display some information about the current window.
           l           Move to the previously selected window.
           n           Change to the next window.
           o           Select the next pane in the current window.
           p           Change to the previous window.
           q           Briefly display pane indexes.
           r           Force redraw of the attached client.
           s           Select a new session for the attached client interactively.
           L           Switch the attached client back to the last session.
           t           Show the time.
           w           Choose the current window interactively.
           x           Kill the current pane.
           {           Swap the current pane with the previous pane.
           }           Swap the current pane with the next pane.
           ~           Show previous messages from tmux, if any.
           Page Up     Enter copy mode and scroll one page up.
           Up, Down
           Left, Right
                       Change to the pane above, below, to the left, or to the right of the current pane.
           M-1 to M-5  Arrange panes in one of the five preset layouts: even-horizontal, even-vertical, main-horizontal, main-vertical, or tiled.
           M-n         Move to the next window with a bell or activity marker.
           M-o         Rotate the panes in the current window backwards.
           M-p         Move to the previous window with a bell or activity marker.
           C-Up, C-Down
           C-Left, C-Right
                       Resize the current pane in steps of one cell.
           M-Up, M-Down
           M-Left, M-Right
                       Resize the current pane in steps of five cells.

从源码编译tmux

# 由于系统默认libevent版本太旧了所以安装了一套新版本的libevent到独立的目录,在编译tmux时需要指定此目录
./configure CFLAGS="-I/usr/local/libevent-2.1.11/include" LDFLAGS="-L/usr/local/libevent-2.1.11/lib" --prefix=$HOME/local/tmux-3.3a/
make -j 20 && make install
# 同时需要在~/.bashrc文件中把/usr/local/libevent-2.1.11/lib/路径增加到LD_LIBRARY_PATH变量中:
export LD_LIBRARY_PATH=/usr/local/libevent-2.1.11/lib/:$LD_LIBRARY_PATH
# 为了覆盖系统自带的tmux命令,还需要在~/.bashrc中增加PATH环境变量的指定:
export PATH=$HOME/local/tmux-3.3a/bin:$PATH

配置securecrt或者xshell自动登录后连接tmux

在会话选项中,找到登录动作,然后增加一条:
期望文本为~]$
发送文本为tmux new -A -s session_name
(要求tmux版本在2以上)

隐藏和连接某一个pane

# 相当于把当前的pane移动到一个新的window中,成为一个独占整个window的pane
break-pane -dP
# 相当于将session名为1的第2个window中的第0个pane移动到当前pane所在位置的左边或者下面,-v指定为下面,-h执行为左边
join-pane -vs 1:2.0
posted @ 2017-09-07 14:52  写bug的民工  阅读(234)  评论(0编辑  收藏  举报