使用 tmux 窗口分割 - 迁

tmux 可以利用 epel yum install 安装

常用方法:

tmux  #进入tmux

ctrl + c #创建一个新的窗口

Ctrl+b q - 显示分隔窗口的编号
c-b w 通过上下键选择当前窗口中打开的会话

进入某个session
tmux attach -t <session>

重绘窗口大小
tmux at -d

杀掉整个session
tmux kill-session -t tm1

退出tumx,并保存当前会话,这时,tmux仍在后台运行,可以通过tmux attach进入 到指定的会话
C-b d 

c-b [ 进入copy模式,可以滚屏 
c-b 方向键 可以选择window-name
c-b x 干掉当前wn
c-b w 查看session,用来选择
c-b % 水平分割
c-b \" 垂直分割
c-b : 进入命令配置模式

 

注意:window 的历史内容已经被 tmux 接管了,所以原来 console/terminal 提供的 Shift+PgUp/PgDn 所显示的内容并不是当前窗口的历史内容,所以要用 C-b [进入 copy-mode,然后才能用 PgUp/PgDn / 光标 / Ctrl-S 等键在 copy-mode 中移动。翻页以看到前面的东西:C-b pageup/pagedown
如果要启用鼠标滚轮来卷动窗口内容的话,可以按 C-b : 然后输入

setw mode-mouse on

这就可以了。如果要对所有窗口开启的话:

setw -g mode-mouse on

(这种情况下,Vi/Emacs 等全屏程序并不受影响,还可以自己接管滚轮事件)
也可以加到~/.tmux.conf 里面

set-window-option -g mode-mouse on

c create new window
n/p move to next/previous windows
f find window by name
w menu with all windows
& kill current window
, rename window

关于 session 和 window-name,只有在同一个 session 里面才能选择 windows

#新建终端
tmux new -d -s tm1
tmux new -d -s tm2
tmux new -d -s tm3
tmux new -d -s tm4
tmux new -d -s tm0
#新建分屏
tmux neww -n 123 -t tm0
tmux neww -n 12 -t tm0
tmux neww -n 1 -t tm0
tmux selectw -t tm0:2
tmux splitw -h -p 50 -t tm0:2

#访问终端
tmux attach -t tm0

tmux selectp -t tm1
tmux splitw -h -p 50
tmux selectp -t tm1
tmux splitw -v -p 50
tmux selectp -t tm1
tmux attach -t tm1
tmux neww -n 1234 -t tm1

 

最后关于 tmux 中新建 (new) 的一些用法

new
new-session [-d] [-n window-name] [-s session-name] [-t target-session] [shell-command]

neww
new-window [-adk] [-n window-name] [-t target-window] [shell-command]

 

posted @ 2017-11-08 12:17  richardzgt  阅读(7495)  评论(0编辑  收藏  举报