Abstract
Tmux is a commond line based tool that enable you to open multiple windowns, tabs or sessions in one terminal. With that, you can work on multiple tasks efficiently as you can separate them in different tmux sessions.
Content
In following part, we may use a command or keyboard-shortcut to achieve our request.
- command usually starts with
tmux
, which would input to terminal. - keyboard-shortcut usually starts with
ctral+b
, which would only work when you’re in a terminal window that attaching session.
tmux session related
Keep in mind that the both attached&detached session would still keep running the program. It’s quite useful when you’re working on a remote server, the program would keep running in detached session even though you may disconnected with remote server.
A session would have an unique session-idx, it’s assigned when created, and is self increased (start by 0).
- start a new session:
tmux
ortmux new -s <session-name>
. - list all existing sessions:
tmux ls
ortmux list-session
orctrl+b s
. - detach existing session:
tmux detach
orctrl+b d
. - attach existing session:
tmux attach -t session-idx
ortmux attach -t session-name
. - kill existing session:
tmux kill-session -t session-idx
ortmux kill-session -t session-name
. - switch attached session:
tmux switch -t session-idx
ortmux switch -t session-name
. - rename session:
tmux rename-session -t session-idx new_session-name
orctrl+b $
.
tmux window related
A session could have multiple windows. Following commands or keyboard-shortcut requires you’re in terminal attaching a session.
- create a new window:
tmux new-window
ortmux new-window -n <window-name>
orctrl+b c
- select window:
tmux select-window -t <window-idx>
ortmux select-window -t <window-name>
orctrl+b <window-idx>
- rename window:
tmux rename-window <new-name>
orctrl+b ,
- switch window:
ctrl+b n
for next orctrl+b p
for prev` - list window:
ctrl+b w
tmux pane related
A window could have multiple panes. Following commands or keyboard-shortcut requires you’re in terminal attaching a session.
- split window to panes horizontally:
tmux split-window -h
orctrl+b %
. - split window to panes vertically:
tmux split-window
orctrl+b "
. - select up pane:
tmux select-pane -U
orctrl+b <up arrow>
. - select down pane:
tmux select-pane -D
orctrl+b <down arrow>
. - select left pane:
tmux select-pane -L
orctrl+b <left arrow>
. - select right pane:
tmux select-pane -R
orctrl+b <right arrow>
. - move up current pane:
tmux swap-pane -U
. - move down current pane:
tmux swap-pane -D
. - ajust pane size: `ctrl+b ctrl+
. - turn on/off fullsize on current pane:
ctrl+b z
.
Questions
History
- 2023-02-25: create post to record the most commonly used commands