Prerequisites
- Tmux installed.
- The default tmux prefix is
ctrl-b
. Knowing this, you can now run the commands from the ‘within tmux’ section below.
- Commands that begin with
tmux
are to be run on the command line.
Tmux config
tmux.config
You can use the config to remap keys. see my tmux config file
Open tmux.config
Source new tmux config file changes
1
| :source-file ~/.tmux.conf
|
Create a new tmux session and give it a name
Attach session
Go back into an existing session.
List sessions
Exit session
Exit the session but keep it alive so you can attach to it again.
Kill all sessions
Kill a specific session
first list the sessions
or
Then choose one to kill
1
| tmux kill-session -t targetSession
|
Enable vi navigation keys to move the cursor around. copy and paste content from previous commands using your vim keys
Attach an existing session to your current shell window
- tmux attach -t (for target) name of session
Plugins
add plugins to your tmux config
1
2
3
4
5
| # list plugins
set -g @plugin 'christoomey/vim-tmux-navigator'
set -g @plugin 'jimeh/tmux-themepack'
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'tmux-plugins/tmux-continuum'
|
Install plugins
Plugin config
config plugins using tmux.config
1
2
| set -g @resurrect-capture-pane-contents 'on'
set -g @continuum-restore 'on'
|
Troubleshooting
- macOS fix for “warning: reattach-to-user-namespace: unsupported new OS, trying as if it were 10.10”
1
| brew upgrade reattach-to-user-namespace
|
more info
more info
My tmux config file
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
| # remap prefix from 'C-b' to 'C-a'
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix
set -g default-terminal "screen-256color"
# horizonal and vertical split planes
unbind %
bind | split-window -h
unbind '"'
bind - split-window -v
# resize panes
bind -r j resize-pane -D 5
bind -r k resize-pane -U 5
bind -r l resize-pane -R 5
bind -r h resize-pane -L 5
# maximise pane
bind -r m resize-pane -X
set -g mouse on
bind-key -T copy-mode-vi 'v' send -X begin-selection
bind-key -T copy-mode-vi 'y' send -X copy-selection
unbind -T copy-mode-vi MouseDragEnd1Pane
# source config with prefix r
unbind r
bind r source-file ~/.tmux.conf
# plugin manager
set -g @plugin 'tmux-plugins/tmp'
# list plugins
set -g @plugin 'christoomey/vim-tmux-navigator'
set -g @plugin 'jimeh/tmux-themepack'
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'tmux-plugins/tmux-continuum'
set -g @resurrect-capture-pane-contents 'on'
set -g @continuum-restore 'on'
set -g @themepack 'powerline/default/cyan'
# keep at the bottom
run '~/.tmux/plugins/tpm/tpm'
# restore vim buffers
set -g @resurrect-processes 'vim:all'
|
Within Tmux
see tmux commands