# tmux
tmux is a terminal multiplexer. It lets you switch easily between several programs in one terminal, detach them (they keep running in the background) and reattach them to a different terminal.
# Config
# set the terminals
set-option -g default-terminal "screen-256color"
set-option -sa terminal-overrides ',xterm-256color:RGB'
# set default shell by OS
if-shell "uname | grep -q Darwin" "set -g default-shell /opt/homebrew/bin/fish"
if-shell "uname | grep -q Linux" "set -g default-shell /home/linuxbrew/.linuxbrew/bin/fish"
# very large history
set -g history-limit 1000000
# base settings
set -g clock-mode-style 12
set -g focus-events on
set -g history-limit 50000
set -g status-keys vi
set -gs escape-time 0 # TODO investigate `-s` flag
# window settings
setw -g clock-mode-style 12
setw -g mode-keys vi
# enable clipboard (OSC 52)
set -g set-clipboard on
# start windows and pane numbering with index 1 instead of 0
set -g base-index 1
setw -g pane-base-index 1
# re-number windows when one is closed
set -g renumber-windows on
# remove confirm step when killing a window or pane
bind-key & kill-window
bind-key x kill-pane
# begin selection with `v` (vi-like)
bind-key -T copy-mode-vi 'v' send-keys -X begin-selection
# Window related bindings
# Open a new pane or window with the current directory of the current pane,
# not the directory in which the first tmux session was started.
bind '"' split-window -c "#{pane_current_path}"
bind % split-window -h -c "#{pane_current_path}"
bind c new-window -c "#{pane_current_path}"
# Keyboard shortcut bindings
bind C-b last-window
bind C-h resize-pane -L 5
bind C-j resize-pane -D 5
bind C-k resize-pane -U 5
bind C-l resize-pane -R 5
bind C-n next-window
bind C-p previous-window
bind g new-window -c "#{pane_current_path}" -n "lazygit" lazygit
bind K new-window -c "#{pane_current_path}" -n "lazydocker" lazydocker
bind S new-window -c "#{pane_current_path}" -n "spotify" spt
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
bind v new-window -c "#{pane_current_path}" nvim +Files
# Set title
set -g set-titles on
set -g set-titles-string "#T"
# Mouse bindings
bind-key -n MouseUp2Status kill-window -t= # Middle click on the window label to kill it
bind-key -n DoubleClick1Status new-window # Double click on the window list to open a new window
set -g mouse on
# copy-mode-vi bindings
bind-key -T copy-mode-vi 'C-h' select-pane -L
bind-key -T copy-mode-vi 'C-j' select-pane -D
bind-key -T copy-mode-vi 'C-k' select-pane -U
bind-key -T copy-mode-vi 'C-l' select-pane -R
bind-key -T copy-mode-vi 'C-\' select-pane -l
# Theme
set -g status-style 'bg=default,fg=white' # transparent status bar
set -g status-position top
set -g pane-active-border-style "fg=green,bg=default"
set -g pane-border-style "fg=white,bg=default"
set -g window-status-format "#[fg=brightblack,bg=default](#[fg=white,bg=default]#I #F #W#[fg=brightblack,bg=default])"
set -g window-status-current-format "#[fg=brightblack,bg=default](#[fg=magenta,bold,bg=default]#I #F #W#[fg=brightblack,nobold,bg=default])"
set -g status-left-length 50
set -g status-left "#[fg=cyan,bold,bg=default] #S " # session name
if-shell "uname | grep -q Darwin" "set -ga status-left '#[fg=brightblack,nobold,bg=default]['"
if-shell "uname | grep -q Darwin" "set -ga status-left '#(gitmux -cfg $HOME/.config/tmux/gitmux.conf)'"
if-shell "uname | grep -q Darwin" "set -ga status-left '#[fg=brightblack,bg=default]] '"
set -g status-right-length 100
if-shell "uname | grep -q Linux" "set -g status-right '#[fg=cyan,bold,bg=default]%l:%M %a, %b %d '"
if-shell "uname | grep -q Linux" "set -ga status-right '#[fg=black,bold,bg=cyan] '"
if-shell "uname | grep -q Darwin" "set -g status-right '#[fg=white,bold,bg=default]%l:%M %a, %b %d '"
if-shell "uname | grep -q Darwin" "set -ga status-right '#[fg=black,bold,bg=white] '"
# Plugins configurations
set -g @emulate-scroll-for-no-mouse-alternate-buffer 'on'
# Plugins
set -g @plugin 'carlocab/tmux-nvr'
set -g @plugin 'christoomey/vim-tmux-navigator'
set -g @plugin 'nhdaly/tmux-better-mouse-mode'
set -g @plugin 'tmux-plugins/tmux-urlview'
set -g @plugin 'tmux-plugins/tpm'
# Plugins Initialization (end of file)
run '~/.tmux/plugins/tpm/tpm'
Server edition: this goes a long way without the plugin code. <<< @/../server/.tmux.conf
# Commands
# Reload config
tmux source ~/.config/tmux/tmux.conf
# tpm
~/.tmux/plugins/tpm/bin/install_plugins
~/.tmux/plugins/tpm/bin/clean_plugins # uninstall / remove
~/.tmux/plugins/tpm/bin/update_plugins all