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]