A Brief intro to tmux



tmux (terminal multiplexer)

  • create multiple sessions in a single terminal
  • keep sessions running even after logoff
  • allow others to connect to running sessions

Alternative to screen


CTRL + B is your friend

CTRL+b, new -s session_name Create new named session
CTRL+b, c Create new window
CTRL+b, , Rename window
CTRL+b, w List windows
CTRL+b, l Move to previously selected window
CTRL+b, n Move to next window
CTRL+b, p Move to previous window
CTRL+b, d Leave session
CTRL+b, s List sessions
CTRL+b, ? List all keybindings
CTRL+b, % Split into vertical panes
CTRL+b, ” Split into horizontal panes
CTRL+b, {or} Switch between panes
CTRL+b, KeyUp Switch to pane above
CTRL+b, KeyDown Switch to pane below
CTRL+b, KeyLeft Switch to pane to the left
CTRL+b, KeyRight Switch to pane to the right  

to start tmux


from a terminal


~ % tmux

NO WINDOW MANAGER REQUIRED

Create your own IDE


SPLIT HORIZONTAL

CTRL + b then  "


SPLIT VERTICAL

CTRL + b then %

Create your own IDE

My .tmux.conf

set -g default-terminal "screen-256color"

setw -g mode-keys vi
set -g mode-mouse on
bind C-c run "tmux show-buffer | xclip -i -selection clipboard"
bind C-v run "tmux set-buffer -- \"$(xclip -o -selection clipboard)\"; tmux paste-buffer"

bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
bind h select-pane -L
###COLOUR - Solarized

# default statusbar colors
set-option -g status-bg colour235 #base02
set-option -g status-fg colour136 #yellow
set-option -g status-attr default

# default window title colors
set-window-option -g window-status-fg colour244
set-window-option -g window-status-bg default
set-window-option -g window-status-attr dim

# active window title colors
set-window-option -g window-status-current-fg colour166 #orange
set-window-option -g window-status-current-bg default
set-window-option -g window-status-current-attr bright

# pane border
set-option -g pane-border-fg colour225 #base02
set-option -g pane-active-border-fg colour240 #base01

# message text
set-option -g message-bg colour235 #base02
set-option -g message-fg colour166 #orange

# pane number display
set-option -g display-panes-active-colour colour33 #blue
set-option -g display-panes-colour colour166 #orange

# clock
set-window-option -g clock-mode-colour colour64 #green

detach


CTRL + b then  d


RE-ATTACH


~% tmux attach



demo

Pair programming?

All you need is...

ssh - public key
tmux
editor

Non-tmux alternatives


Integration with other tools

vim

emacs

iterm2






demo




Resources



Workflow

intro to tmux

By nathan claburn

intro to tmux

  • 116