Set up tmux
Install it:
sudo apt install tmux
Add this to your ~/.bashrc
(or ~/.zshrc
if you use zsh):
if [[ -z $TMUX ]]; then
tmux
fi
This automatically starts tmux when you open a terminal.
Note: If you use powerlevel10k, set this code before the instant prompt preamble.
How to use
Splitting
To split terminal vertically, press Ctrl-b
, release them and then press %
. For horizontal split, press "
instead of %'. Make sure to release the keys before you press
% or
”`.
Coomand Cheat Sheet
tmux Command Cheat Sheet
Session Management
Start tmux:
tmux
Create a new session:
tmux new -s <session-name>
List sessions:
tmux ls
Attach to a session:
tmux attach -t <session-name>
Detach from a session:
Ctrl-b d
Kill a session:
tmux kill-session -t <session-name>
Window Management
Create a new window:
Ctrl-b c
Switch between windows:
Ctrl-b <window-number>
Rename a window:
Ctrl-b ,
(then type the name) Close a window:
Ctrl-b &
Pane Management
Split horizontally:
Ctrl-b "
Split vertically:
Ctrl-b %
Switch between panes:
Ctrl-b <arrow-keys>
(or use Ctrl-b o
to cycle through)
Resize pane:
Ctrl-b
then:
→
or ←
(resize horizontally)
↑
or ↓
(resize vertically)
Kill a pane:
Ctrl-b x
Miscellaneous
Command prompt:
Ctrl-b :
(for advanced commands like kill-pane
, rename-session
, etc.)
Scroll through history:
Ctrl-b [
(use arrow keys or PgUp/PgDn
to scroll, then press q
to quit)
Synchronize panes:
Ctrl-b :
then type:
setw synchronize-panes on
Copy-Paste Mode
Enter copy mode:
Ctrl-b [
Start selection:
Space
Copy selection:
Enter
Paste:
Ctrl-b ]