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:
tmuxortmux new -s <session-name>. - list all existing sessions:
tmux lsortmux list-sessionorctrl+b s. - detach existing session:
tmux detachorctrl+b d. - attach existing session:
tmux attach -t session-idxortmux attach -t session-name. - kill existing session:
tmux kill-session -t session-idxortmux kill-session -t session-name. - switch attached session:
tmux switch -t session-idxortmux switch -t session-name. - rename session:
tmux rename-session -t session-idx new_session-nameorctrl+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-windowortmux 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 nfor next orctrl+b pfor 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 -horctrl+b %. - split window to panes vertically:
tmux split-windoworctrl+b ". - select up pane:
tmux select-pane -Uorctrl+b <up arrow>. - select down pane:
tmux select-pane -Dorctrl+b <down arrow>. - select left pane:
tmux select-pane -Lorctrl+b <left arrow>. - select right pane:
tmux select-pane -Rorctrl+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