jasonwryan.com

Miscellaneous ephemera…

tmux - terminal multiplexer

Over the last couple of days I have been familiarising myself with tmux. As it says on the homepage,

tmux is a terminal multiplexer: it enables a number of terminals (or windows), each running a separate program, 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.

I was attracted to tmux after seeing a number of enthusiastic postings on the Arch forums, and by the promise of better management of multiple terminals in a single dwm tag

It’s available in the community repo, so:

1
pacman -S tmux

Then it is just a matter of configuring it to suit your style of working, keyboard bindings etc. Helpfully, it comes with some example config files to start you off. These can be found at /usr/share/tmux/*.conf. I borrowed heavily from Thayer Williams' for mine:

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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# set prefix key to ctrl+t
unbind C-b
set -g prefix C-t

# more intuitive keybindings for splitting
unbind %
bind h split-window -h
unbind '"'
bind v split-window -v

# set vi keys
unbind [
bind Escape copy-mode
setw -g mode-keys vi

# send the prefix to client inside window (ala nested sessions)
bind-key a send-prefix

# toggle last window like screen
bind-key C-b last-window

# confirm before killing a window or the server
bind-key k confirm kill-window
bind-key K confirm kill-server

# toggle statusbar
bind-key b set-option status

# ctrl+left/right cycles thru windows
bind-key -n C-right next
bind-key -n C-left prev

# open a man page in new window
bind / command-prompt "split-window 'exec man %%'"

# quick view of processes
bind '~' split-window "exec htop"

# scrollback buffer n lines
set -g history-limit 5000

# on-screen time for display-panes in ms
set -g display-panes-time 2000

# start window indexing at one instead of zero
set -g base-index 1

# enable wm window titles
set -g set-titles on

# wm window title string (uses statusbar variables)
set -g set-titles-string "tmux:#I #W"

# session initialization
new -s TTYtter ttytter
neww -t 2
neww -d -t 3
neww -d -t 5
selectw -t 1

#### statusbar ####
set -g status-interval 1
set -g status-justify centre # center align window list
set -g status-left '#[fg=green] #H #[default]'
set -g status-right '#[fg=blue,bright]Up#(uptime | cut -f 4-5 -d " " | cut -f 1 -d ",") 
#[default]:: #[fg=cyan]#(cut -d " " -f 1-4 /proc/loadavg) '

# default statusbar colors
set -g status-fg white
set -g status-bg default
set -g status-attr bright

# default window title colors
set-window-option -g window-status-fg white
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 white
set-window-option -g window-status-current-bg default
set-window-option -g window-status-current-attr bright

# command/message line colors
set -g message-fg white
set -g message-bg black
set -g message-attr bright

Copy this file to ~/.tmux.conf. The final result:

Archlinux:  tmux running in dwm

Updated 16/11/10

For a current version of my .tmux.conf, check my mercurial repository.

Comments