8/14/25
Intro
![]()
tmux 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
Using tmux
Setup
- install tmux
sudo apt update
sudo apt install tmuxActivate mouse support
- Enable mouse mode
set -g mouse onConfigure tmux
- Create a
/tmux.conffile that tmux runs when tmux server is started
nano ~/.tmux.conf- Example: Add command for mouse support
# Enable mouse mode
set -g mouse on- Apply changes
tmux source-file ~/.tmux.confUseful commands
- start tmux
tmux- Detach from session
Ctrl+B then D- list active tmux sessions
tmux ls0: 1 windows (created Thu Aug 14 21:43:07 2025)
- reattach
$ tmux attach -t 0
- Single line command to start 4 panes
tmux kill-session -t dev 2>/dev/null; tmux new-session -s dev -n dev \; split-window -h \; split-window -v -t 0 \; split-window -v -t 1 \; select-layout tiled \; select-pane -t 0- Result
+-------+-------+
| pane0 | pane1 |
+-------+-------+
| pane2 | pane3 |
+-------+-------+
Keybindings
Keybindings
Key Combination Description Ctrl+B D Detach from the current session Ctrl+B % Split the window into two panes horizontally Ctrl+B “ Split the window into two panes vertically Ctrl+B Arrow Key (← ↑ ↓ →) Move between panes Ctrl+B X Close pane Ctrl+B C Create a new window Ctrl+B N / Ctrl+B P Move to the next or previous window Ctrl+B 0 (1,2…) Move to a specific window by number Ctrl+B : Enter the command line (tab completion available) Ctrl+B ? View all keybindings (press Q to exit) Ctrl+B W Open a panel to navigate across windows in multiple sessions
Sample workflow
- start session
tmux- split screen verically
Ctrl+b % - split screen horizontally
Ctrl+b " - run commands in each pane independently
8/31/25
Tmux bash scripts
WSL
mkdir -p ~/bin && cd ~/bin- Add
~/bintoPATHin WSL
echo 'export PATH="$HOME/bin:$PATH"' >> ~/.bashrc- Reload shell
source ~/.bashrc- Create a
devbash script [^2] to start tmux with 4 evenly-split panes
#!/bin/bash
tmux kill-session -t dev 2>/dev/null
SESSION="dev"
# Start a new tmux session in detached mode
tmux new-session -d -s $SESSION
# Split the window horizontally (Pane 1)
tmux split-window -h -t $SESSION
# Split Pane 0 vertically (Pane 2)
tmux split-window -v -t $SESSION:0.0
# Split Pane 1 vertically (Pane 3)
tmux split-window -v -t $SESSION:0.1
# Apply the 'tiled' layout to arrange panes evenly
tmux select-layout -t dev tiled
# Focus back on Pane 0
tmux select-pane -t $SESSION:0.0
# Attach to the session
tmux attach-session -t $SESSION- Make executable
chmod +x dev- Run script
dev- Resulting layout
+---------+---------+
| Pane 0 | Pane 1 |
| | |
+---------+---------+
| Pane 2 | Pane 3 |
| | |
+---------+---------+
- Kill the session (or press Ctrl + D to exit each pane)
tmux kill-session -t devUse bash script in Docker
- Add
\bindirectory todocker-compose.ymlas a volume mount
volumes:
- ~/bin:/root/bin- Inside NoVNC, add
/root/bintoPATH
echo 'export PATH="/root/bin:$PATH"' >> ~/.bashrc- Run script
dev- Resulting layout





