Table of Contents
-
Start a tmux session with
tmux
-
Select text in a tmux window with your mouse by holding the
SHIFTkey (Windows) or theOPTIONSkey (Mac) and then using the mouse as you'd normally do
| Key(s) | Description |
|---|---|
CTRL+b <command> |
sends <command> to tmux instead of sending it to the shell |
| General Commands | |
? |
shows a list of all commands (qcloses the list) |
: |
enter a tmux command |
| Working with Windows | |
c |
creates a new window |
, |
rename current window |
p |
switch to previous window |
n |
switch to next window |
w |
list windows (and then select with arrow keys) |
| Working with Panes | |
% |
split window vertically |
- |
split window horizontally requires bind - split-window -v in our .tmux.conf |
| → | go to right pane |
| ← | go to left pane |
| ↑ | go to upper pane |
| ↓ | go to lower pane |
| Working with Sessions | |
d |
detach from session |
| Command | Description |
|---|---|
| tmux -s | creates a new session with name <SESSION NAME> |
| tmux list-sessions | lists all currently running tmux sessions |
| tmux attach -t | attach to the session called <SESSION NAME> |
Start a new tmux session with tmux before running the script!
#!/bin/bash
SESSION=$USER
tmux -2 new-session -d -s $SESSION
tmux new-window -t $SESSION:1 -n "TMUX-Test"
tmux split-window -h
tmux select-pane -t 0
tmux send-keys "echo 'pane1'" C-m
tmux select-pane -t 1
tmux send-keys "echo 'pane2'" C-m
tmux split-window -v
tmux send-keys "echo 'pane3'" C-mYou can configure tmux via the ~/.tmux.conf file. After making changes to the config file, you can update the configuration "on-the-fly" with
tmux source ~/.tmux.conf
Use
set -g prefix C-ato change the default prefix from CTRL + b to CTRL + a. Optionally you can "free" the default binding with
unbind C-bYou can add / alter tmux's key bindings with the following command
bind | split-window -hthis binds the split window -h command to the | key.
In order to have mouse support in Mac OS X, you can add the following lines to your config file:
set -g mode-mouse on
set -g mouse-resize-pane on
set -g mouse-select-pane on
set -g mouse-select-window on