A Simple TMUX Tutor
程序员文章站
2023-04-06 11:12:34
"Tmux Wiki" "Installation of CentOS7" "Introduction" "Key Bindings" "Configuring ~/.tmux.conf" "References" Tmux Wiki The follow contents is mainly re ......
tmux wiki
the follow contents is mainly reprinted of learn x in y minutes - tmux.
installation of centos7
# dependce packages yum install ncurses-devel libevent-devel # download source code package wget https://github.com/tmux/tmux/releases/download/2.8/tmux-2.8.tar.gz # extract & make & make install tar -zxvf tmux-2.8.tar.gz cd tmux-2.8 ./configure --prefix=/opt/tmux make && make install # set path export path=$path:/opt/tmux/bin
introduction
is a terminal multiplexer: it enables a number of terminals to be created, accessed, and controlled from a single screen. tmux may be detached from a screen and continue running in the background then later reattached.
tmux conform c/s mode, including followed modules:
- server - run
tmux
in terminal to start a server; - session - a server can include serveral sessions;
- window - a session can include serveral windows;
- pane - a window can include serveral panes.
directive | description |
---|---|
tmux [command] | run a command |
'tmux' with no commands will create a new session | |
command/option | |
[new] | create a new session |
-s "session" | create named session |
-n "window" | create named window |
-c "/dir" | start in target directory |
[attach] | attach last/available session |
-t "#" | attach target session |
-d | detach the session from other instances |
[ls] | list open sessions |
-a | list all open sessions |
[lsw] | list windows |
-a | list all windows |
-s | list all windows in session |
[lsp] | list panes |
-a | list all panes |
-s | list all panes in session |
-t | list all panes in target |
[kill-window] | kill current window |
-t "#" | kill target window |
-a | kill all windows |
-a -t "#" | kill all windows but the target |
[kill-session] | kill current session |
-t "#" | kill target session |
-a | kill all sessions |
-a -t "#" | kill all sessions but the target |
key bindings
the method of controlling an attached tmux session is via key combinations called 'prefix' keys.
key | description |
---|---|
c-b | 'prefix' combination required to use keybings |
m-1 | |
system | |
? | list all key bindings |
: | enter the tmux command prompt |
r | force redraw of the attached client |
t | show current time |
d | detach the current client |
d | choose a client to detach |
[ | enter copy mode to copy text or view history. |
~ | show info messages |
s | select a new session for the attached client |
window | |
c | create a new window |
n | change to the next window |
p | change to the previous window |
l | switch to last window |
w | choose the current window interactively |
& | kill the current window |
0-9 | select windows 0 to 9 |
, | rename current window |
. | renumber current window no. |
f | find plain in all windows |
pane | |
% | split the current pane into two, left and right |
" | split the current pane into two, top and bottom |
q | show no. of splited panes |
; | switch to last pane |
u/d/l/r | change to the pane above, below, left, or right |
! |
break the current pane out of the window. |
x | kill the current pane |
o | switch to next pane in current window |
c-o | rotate all panes anti-clockwise |
m-o | rotate all panes clockwise |
c-u/d/l/r | resize the current pane in steps of one cell |
m-u/d/l/r | resize the current pane in steps of five cells |
space | toggle in preset pane layouts including even-horizontal, even-vertical, main-horizontal, main-vertical, tiled |
{ | swap the current pane with the previous pane |
} | swap the current pane with the next pane |
m-1 to m-5 | arrange panes |
m-1 | even-horizontal |
m-2 | even-vertical |
m-3 | main-horizontal |
m-4 | main-vertical |
m-5 | tiled |
configuring ~/.tmux.conf
tmux.conf
can be used to set options automatically on start up, much like how .vimrc
or init.el
are used.
# example tmux.conf ### general # scrollback/history limit set -g history-limit 2048 # index start set -g base-index 1 # mouse set-option -g -q mouse on # force reload of config file unbind r bind r source-file ~/.tmux.conf ### keybinds # unbind c-b as the default prefix unbind c-b # set new default prefix set-option -g prefix ` # return to previous window when prefix is pressed twice bind c-a last-window bind ` last-window # allow swapping c-a and ` using f11/f12 bind f11 set-option -g prefix c-a bind f12 set-option -g prefix ` # keybind prefrence setw -g mode-keys vi set-option -g status-keys vi # moving between panes with vim movement keys bind h select-pane -l bind j select-pane -d bind k select-pane -u bind l select-pane -r # window cycle/swap bind e previous-window bind f next-window bind e swap-window -t -1 bind f swap-window -t +1 # easy split pane commands bind = split-window -h bind - split-window -v unbind '"' unbind % # activate inner-most session (when nesting tmux) to send commands bind a send-prefix ### theme # statusbar color palatte set-option -g status-justify left set-option -g status-bg black set-option -g status-fg white set-option -g status-left-length 40 set-option -g status-right-length 80 # pane border color palette set-option -g pane-active-border-fg green set-option -g pane-active-border-bg black set-option -g pane-border-fg white set-option -g pane-border-bg black # message color palette set-option -g message-fg black set-option -g message-bg green # window status color palette setw -g window-status-bg black setw -g window-status-current-fg green setw -g window-status-bell-attr default setw -g window-status-bell-fg red setw -g window-status-activity-attr default setw -g window-status-activity-fg yellow ### ui # notification setw -g monitor-activity on set -g visual-activity on set-option -g bell-action any set-option -g visual-bell off # automatically set window titles set-option -g set-titles on set-option -g set-titles-string '#h:#s.#i.#p #w #t' # window number,program name,active (or not) # statusbar adjustments set -g status-left "#[fg=red] #h#[fg=green]:#[fg=white]#s#[fg=green] |#[default]" # show performance counters in statusbar # requires https://github.com/thewtex/tmux-mem-cpu-load/ set -g status-interval 4 set -g status-right "#[fg=green] | #[fg=white]#(tmux-mem-cpu-load)#[fg=green] | #[fg=cyan]%h:%m #[default]"
references
推荐阅读
-
用Simple Excel导出xls实现方法
-
基于simple_html_dom的使用小结
-
GS Typing Tutor如何激活?打字练习软件GS Typing Tutor安装激活教程(附补丁+软件)
-
清空MSSQL日志 与set recovery simple
-
PHP排序算法之简单选择排序(Simple Selection Sort)实例分析
-
浅谈mvvm-simple双向绑定简单实现
-
linux下终端分屏使用的两种方法(screen和tmux)
-
PHP simple_html_dom.php+正则 采集文章代码
-
Net设计模式实例之简单工厂模式(Simple Factory Pattern)
-
在Python的Django框架中simple-todo工具的简单使用