Files
dotfiles/tmux/.tmux.conf
2022-11-01 22:29:08 +02:00

116 lines
3.6 KiB
Bash

# NOTE: First of all install TPM
# git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
unbind-key C-b
set-option -g prefix C-a
bind-key C-a send-prefix
# Set the base index for windows to 1 instead of 0.
set -g base-index 1
# Set the base index for panes to 1 instead of 0.
set -g pane-base-index 1
# Vi-mode
set -g mode-keys vi
# Enable activity alerts.
set -g visual-activity off
# Renumber windows when a window is closed
set -g renumber-windows on
# https://github.com/tmux/tmux/issues/353#issuecomment-265154018
set -g focus-events off
# https://gist.github.com/andersevenrud/015e61af2fd264371032763d4ed965b6
set -g default-terminal "tmux-256color"
set -ag terminal-overrides ",xterm-256color:RGB"
# => Theme
set -g status-style fg=white,bg=black
set -g window-status-current-style fg=black,bg=white,bold
set -g window-status-style fg=colour244,bg=default
set -g window-status-current-style fg=colour166,bg=default
set -g message-style fg=colour166,bg=colour235
set -g window-status-format " ━━━━━━ "
set -g window-status-current-format " ━━━━━━ "
set -g status-left ''
set -g status-right ''
set -g status-justify centre
# Planck
bind-key "'" split-window -h
bind-key "p" split-window -v
bind-key 'q' select-window -t 1
bind-key 'w' select-window -t 2
bind-key 'e' select-window -t 3
bind-key 'r' select-window -t 4
bind-key 't' select-window -t 5
bind-key 'y' select-window -t 6
# Smart pane switching with awareness of Vim splits.
# See: https://github.com/christoomey/vim-tmux-navigator
is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
| grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"
bind-key -n 'C-h' if-shell "$is_vim" 'send-keys C-h' 'select-pane -L'
bind-key -n 'C-j' if-shell "$is_vim" 'send-keys C-j' 'select-pane -D'
bind-key -n 'C-k' if-shell "$is_vim" 'send-keys C-k' 'select-pane -U'
bind-key -n 'C-l' if-shell "$is_vim" 'send-keys C-l' 'select-pane -R'
tmux_version='$(tmux -V | sed -En "s/^tmux ([0-9]+(.[0-9]+)?).*/\1/p")'
if-shell -b '[ "$(echo "$tmux_version < 3.0" | bc)" = 1 ]' \
"bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\' 'select-pane -l'"
if-shell -b '[ "$(echo "$tmux_version >= 3.0" | bc)" = 1 ]' \
"bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\\\' 'select-pane -l'"
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
bind-key C-l send-keys 'C-l'
# => Bindings
# Kill pane without confirmation
bind-key x kill-pane
# Painless copying with tmux-yank
unbind [
bind Escape copy-mode
setw -g mode-keys vi
unbind-key -T copy-mode-vi v
bind-key -T copy-mode-vi 'v' send -X begin-selection # Begin selection in copy mode.
bind-key -T copy-mode-vi 'C-v' send -X rectangle-toggle # Begin selection in copy mode.
bind-key -T copy-mode-vi 'y' send -X copy-pipe-and-cancel "pbcopy" # Yank selection in copy mode.
bind-key -T copy-mode-vi 'H' send -X back-to-indentation
bind-key -T copy-mode-vi 'L' send -X end-of-line
bind N new-session
# => Plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
# Depends on 'urlview'
set -g @plugin 'tmux-plugins/tmux-urlview'
set -g @plugin 'tmux-plugins/tmux-yank'
# Default keysbindings for panes
set -g @plugin 'tmux-plugins/tmux-pain-control'
set -g @plugin 'christoomey/vim-tmux-navigator'
# If run as "tmux attach", create a session if one does not already exist
new-session -A -s default
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'