CONFIG

My tmux config

#org-config
Published — Updated

Not a shell like Bash or Fish, but tmux streamlines the terminal those shells sit in.

Allowed and preferred settings can change significantly between releases, so for you out there in the world: this is my tmux version.

tmux -V
tmux 3.0a

Terminal profile

What kind of terminal should I tell tmux I use?

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

Found some notes about setting terminal-overrides when your terminal supports TrueColor, but so far I’ve had mixed results. Sometimes I try including this bit, but right now I skip it.

# The terminal supports true color
set-option -ga terminal-overrides ',xterm-256color:RGB'
set-option -ga terminal-overrides ',xterm-256color:Tc'

Copying text

Copying and pasting gets weird when you bounce between operating systems.

# See /opt/local/share/doc/tmux-pasteboard/Usage.md
#if-shell 'test "$(uname -s)" = Darwin' 'set-option -g default-command "exec reattach-to-user-namespace -l zsh"'

if-shell "uname | grep -q Darwin" {
  bind-key -T copy-mode-vi 'y' \
    send -X copy-pipe-and-cancel 'reattach-to-user-namespace pbcopy'
  bind-key -T copy-mode-vi Enter \
    send -X copy-pipe-and-cancel 'reattach-to-user-namespace pbcopy'
} {
  bind-key -T copy-mode-vi 'y' \
    send -X copy-pipe-and-cancel 'xclip -in -selection clipboard'
  bind-key -T copy-mode-vi Enter \
    send -X copy-pipe-and-cancel 'xclip -in -selection clipboard'
}

Keybindings

Bit of vim-like behavior borrowed from online tmux configs.

bind c new-window -c "#{pane_current_path}"
bind r source-file ~/.tmux.conf \; display "Reloaded!"

bind \\ split-window -h -c "#{pane_current_path}"
unbind %

bind - split-window -v -c "#{pane_current_path}"
unbind '"'

bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
bind H resize-pane -L 5
bind J resize-pane -D 5
bind K resize-pane -U 5
bind L resize-pane -R 5

Status bar

Put my status bar on the top. Add a clock and Taskwarrior summary.

set -g status on
set -g status-interval 10    # redraw status line after n seconds
set-window-option -g status-position top

# widgets
# See also: https://github.com/samoshkin/tmux-config/blob/master/tmux/tmux.conf
wg_date="#[$color_secondary]%Y-%m-%d %H:%M%z#[default]"
set -g status-right "#{prefix-highlight} #(task-counts) $wg_date"

Colors

Pretty! For me at least.

# default bar color
set-option -g status-style "bg=#1b1c36, fg=#ecf0c1"

# active pane
set -g pane-active-border-style "fg=#fccc96"

# inactive pane
set -g pane-border-style "fg=#686f9a"

# active window
set-option -g window-status-current-style "bg=#686f9a, fg=#ffffff"

# Message
set-option -g message-style "bg=#686f9a, fg=#ecf0c1"
set-option -g message-command-style "bg=#686f9a, fg=#ecf0c1"

# When commands are run
set -g message-style "fg=#0f11b0, bg=#686f9a"

Unsorted

The settings I haven’t managed to fit in a more organized spot.

set -s escape-time 1
set -g mouse on
# via https://github.com/gpakosz/.tmux/blob/master/.tmux.conf
set -g base-index 1          # window numbering
setw -g pane-base-index 1    # pane numbering
set -g renumber-windows on   # renumber when a window closed?
setw -g automatic-rename on # rename window to reflect current program?
set -g set-titles on         # set terminal title

set -g monitor-activity on
set -g visual-activity on

set-window-option -g xterm-keys on
set-window-option -g mode-keys vi

Putting it all together

<<config-tmux-terminal>>

<<config-tmux-clipboard>>

<<config-tmux-unsorted>>

<<config-tmux-keybindings>>

<<config-tmux-statusbar>>

<<config-tmux-colors>>