Logo
Loading...
Published on

Setting up Tmux

Author

I heard a lot about Tmux and tried to use it a few times, but had no luck.

All those keybinds were very uncomfortable, and it was really hard to use.

At some point I found this blog post: https://hamvocke.com/blog/a-guide-to-customizing-your-tmux-conf/.

This was an exceptional guide, and some wonderful quality of life keybinds.

Author has GitHub repository with dotfiles, recommend checking it out.

I will add config here, just for personal use and reference.

Contents of ~/.tmux.conf

# change the prefix from 'C-b' to 'C-a'
# (remap capslock to CTRL for easy access)
unbind C-b
set -g prefix C-a
bind C-a send-prefix

# start with window 1 (instead of 0)
set -g base-index 1

# start with pane 1
set -g pane-base-index 1

# split panes using | and -, make sure they open in the same path
bind | split-window -h -c "#{pane_current_path}"
bind - split-window -v -c "#{pane_current_path}"

unbind '"'
unbind %

# open new windows in the current path
bind c new-window -c "#{pane_current_path}"

# reload config file
bind r source-file ~/.tmux.conf

unbind p
bind p previous-window

# shorten command delay
set -sg escape-time 1

# don't rename windows automatically
set -g allow-rename off

# mouse control (clickable windows, panes, resizable panes)
set -g mouse on

# Use Alt-arrow keys without prefix key to switch panes
bind -n M-Left select-pane -L
bind -n M-Right select-pane -R
bind -n M-Up select-pane -U
bind -n M-Down select-pane -D

# enable vi mode keys
set-window-option -g mode-keys vi

# set default terminal mode to 256 colors
set -g default-terminal "xterm-256color"
set -ga terminal-overrides ",xterm-256color:Tc"

# allow focus events to get through to applications running in tmux
set -g focus-events on


# Design Tweaks
# -------------

# loud or quiet?
set -g visual-activity on
set -g visual-bell on
set -g visual-silence off
setw -g monitor-activity off
set -g bell-action none

#  modes
setw -g clock-mode-colour colour228
setw -g mode-style 'fg=black bg=color217 bold'

# panes
set -g pane-border-style 'fg=color217'
set -g pane-active-border-style 'fg=colour228'

# statusbar
set -g status-position bottom
set -g status-justify left
set -g status-style 'fg=color217'

set -g status-left '#{?client_prefix,#[fg=colour118],#[fg=color217]} '
set -g status-left-length 10


set -g status-right-style 'fg=black bg=colour228'
set -g status-right '#[bg=terminal fg=colour228]#[bg=colour228 fg=black]%Y-%m-%d %H:%M#[bg=terminal fg=colour228]#[bg=colour228 fg=black]'

setw -g window-status-current-style 'fg=black bg=color217 bold'
setw -g window-status-current-format '#[bg=terminal fg=color217]#[bg=color217 fg=black]#I #W #F#[bg=terminal fg=color217]#[bg=color217 fg=black]'

setw -g window-status-style 'fg=color217'
setw -g window-status-separator ''
setw -g window-status-format ' #I #[fg=white]#W #[fg=colour228]#F '

setw -g window-status-bell-style 'fg=colour228 bg=color217 bold'

# messages
set -g message-style 'fg=colour228 bg=terminal bold'