Background

For a long time, my friends and colleagues have been telling me that tmux is so much better than screen, which I used to run for having a persistent IRC client connection back in the days. More recently, I ran into issues with my terminator setup among other things, which led me to reinstall my operating system.

I decided to give tmux a go, and DAMN does it feel handy. I mean my main motivation was just to be able to split terminals when working, and I’m pretty sure I’ve barely scratched the surface of what tmux can do, but I don’t think I’m going back any time soon.

My tmux setup

I told terminal emulator to run tmux instead of a shell whenever I open a terminal. After some weeks I have a tmux config file which I’m reasonably happy with. I still haven’t set up copy/paste to work properly, but copy/paste with shift-mouse works fine for the most part.

# Similar to screen (C-a C-a)
bind-key C-b last-window

# Use colors the same way as screen does
set -g default-terminal "screen-256color"

# Don't wait for escape sequences
set -s escape-time 0

# Enable mouse scrolling
set -g mouse on

# Use vi style bindings
set-window-option -g mode-keys vi

# Move around panes with ALT + arrow keys.
bind-key -n M-Up select-pane -U
bind-key -n M-Left select-pane -L
bind-key -n M-Down select-pane -D
bind-key -n M-Right select-pane -R

# Split panes.
bind-key h split-window -v -c "#{pane_current_path}"
bind-key v split-window -h -c "#{pane_current_path}"
bind-key C-h split-window -v -c "#{pane_current_path}"
bind-key C-v split-window -h -c "#{pane_current_path}"

# Resize panes with C-a + ALT + arrow keys
bind-key M-Up resize-pane -U 10
bind-key M-Left resize-pane -L 10
bind-key M-Down resize-pane -D 10
bind-key M-Right resize-pane -R 10

# Automatically set window title
set-window-option -g automatic-rename on
set-option -g set-titles on

set-option -g status-left-length 40
set-option -g status-left "#{pane_current_path} |"
set-option -g status-style fg=brightyellow,bg=black
set-option -g status-right "#(id -nu)@#h | %Y-%m-%d | %H:%M"

Some notes regarding this

  • Getting colors to work when running vim in tmux was surprisingly difficult, but the screen-256color entry solved that issue
  • As mentioned before, any notes on how to have a nice copy/paste that integrates with the system clipboard would be appreciated. Most posts I’ve seen regarding this seem VERY complicated, does it have to be?
  • I would like to have some kind of status of all sessions I have on this machine as part of the status line, maybe just a list of numbers. I have yet to find a way to include that.
  • Am I missing something that is a must have?