Tmux Help
Tmux Help
- Session: tmux session
- Pane: Terminal within a tmux session
- Prefix Key:
Ctrl + b - Window: Parent Terminal of Pane
- One window can have any number of Panes
- In one tmux session, we can have multiple windows
Getting Started
- To enter tmux:
tmux
Panes
- For a new Pane:
Ctrl + bthen%(for vertical Pane)Ctrl + bthen"(for horizontal Pane)
- To switch between Panes:
Ctrl + bthenarrow-keysCtrl + btheno(to next pane)
- Resizing the Panes:
Ctrl + bthenCtrl + arrow-keys
- For exit (close) Pane:
exit
Windows
- To create a new window:
Ctrl + bthenc- The active window is marked with
* - The window name is shown at the bottom-left
- To switch between windows:
Ctrl + bthenwindow-number(window number can be seen at the bottom-left)
- To rename a window:
Ctrl + bthen,(comma)- Then enter text and press enter
- To exit a window:
exit
Sessions
- To detach the current session:
Ctrl + bthend- We can also directly close the terminal
- To list tmux sessions:
tmux ls - To attach a session:
tmux attach -t session_name_or_number(session-number can be seen from the list)tmux attach(attaches the last session)
- To rename a session:
tmux rename-session -t session-number - To create a session:
tmux new - To create a session with a name:
tmux new -s session_name - To kill/stop a session:
tmux kill-session -t session_name_or_number
Important Commands
- New session & command to execute from CMD:
tmux new 'command_to_execute'Example:
tmux new 'serve -p 3000' - New session & detach mode & command to execute from CMD:
tmux new -d 'command_to_execute'Example:
tmux new -d 'serve -p 3000' - New session with name & detach mode & command to execute from CMD:
tmux new -s session_name -d 'command_to_execute'Example:
tmux new -s s1 -d 'serve -p 3000' - To add a new pane to an existing session from CMD (by default detach mode):
tmux split-window -t session_name_or_number -v 'command_to_execute'Examples:
tmux split-window -t s1 -v 'serve -p 4000'tmux split-window -t s1 -h 'serve -p 5000'-vfor vertical split-hfor horizontal split
- New session & multiple Panes in detach mode:
tmux new -s s1 -d 'serve -p 3000' \; split-window -h -t s1 'top' # top is a commandor
tmux new -s s1 -d 'serve -p 3000' && tmux split-window -h -t s1 'top'