Files
dotfiles/config/tmux/tmux.conf

175 lines
7.3 KiB
Bash

# ~/.config/tmux/tmux.conf, or .dotfiles/config/tmux/tmux.conf
#
# Contains configuration from the following sources:
# - https://tmuxguide.readthedocs.io/en/latest/tmux/tmux.html
# - https://github.com/dreamsofcode-io/tmux/blob/main/tmux.conf
# ╭──────────────────────────────────────────────────────────╮
# │ Bindings │
# ╰──────────────────────────────────────────────────────────╯
# Set <prefix> to Control + Space, keeping the default of C-b intact.
# unbind C-b
set -g prefix C-Space
bind C-Space send-prefix
# Vim style pane selection
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
# 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
# Reload tmux config with <prefix> + r
bind r source-file ~/.dotfiles/config/tmux/tmux.conf \; display "tmux cfg reloaded!"
# Open a new window with <prefix> + N
bind N new-window
# Set default directory for new windows in this session to current directory:
bind M-c attach-session -c "#{pane_current_path}"
# Open a new window in the current directory
bind C new-window -c "#{pane_current_path}"
# keybindings
bind-key -T copy-mode-vi v send-keys -X begin-selection
bind-key -T copy-mode-vi C-v send-keys -X rectangle-toggle
bind-key -T copy-mode-vi y send-keys -X copy-selection-and-cancel
bind '"' split-window -v -c "#{pane_current_path}"
bind '!' split-window -h -c "#{pane_current_path}"
bind '^' switch-client -t'{marked}'
# synchronize all panes in a window
bind y setw synchronize-panes
#### copy mode : vim ####
# copy mode using 'Esc'
unbind [
bind Escape copy-mode
# paste using 'p'
unbind p
bind p paste-buffer
# ╭──────────────────────────────────────────────────────────╮
# │ Settings │
# ╰──────────────────────────────────────────────────────────╯
set -g default-terminal "tmux-256color"
set -ag terminal-overrides ",xterm-256color:RGB"
# Setting status on
set -g status "on"
# Hide clock
set -g display-time 0
# Activity Monitoring (for when something happens in another pain)
set -g monitor-activity on
set -g visual-activity off
set -g visual-bell off
# Expose window title
set-option -g set-titles on
# Set bigger history limit
set -g history-limit 20000
# Keep Tmux alive when the initial command is finished
set -g remain-on-exit off
# Mouse support
set -g mouse on
# Make delay shorter
set -sg escape-time 0
# Start windows and panes at 1, not 0
set -g base-index 1
set -g pane-base-index 1
set-window-option -g pane-base-index 1
set-option -g renumber-windows on
# set vi-mode
set-window-option -g mode-keys vi
# ╭──────────────────────────────────────────────────────────╮
# │ Theme │
# ╰──────────────────────────────────────────────────────────╯
set -g status-left-length "0"
set -g status-right-length "30"
set-option -g status-position "bottom"
set-option -g status-justify left
set-option -g status-left ''
set-option -g window-status-format ' #I:#W '
set-option -g window-status-current-format ' #I:#W#{?window_zoomed_flag, ◈ ,} '
set-option -g status-right "#{hostname_short}/#S #{tmux_mode_indicator}"
set -g pane-border-style "fg=#3b4261"
set -g pane-active-border-style "fg=#7aa2f7"
# https://github.com/erikw/tmux-dark-notify
set -g @dark-notify-theme-path-light '~/.dotfiles/config/tmux/theme-light.conf'
set -g @dark-notify-theme-path-dark '~/.dotfiles/config/tmux/theme-dark.conf'
# ╭──────────────────────────────────────────────────────────╮
# │ Plugins related configurations │
# ╰──────────────────────────────────────────────────────────╯
# Plugin that lets you suspend local tmux session,
# so that you can work with nested remote tmux session painlessly.
# https://github.com/MunifTanjim/tmux-suspend
set -g @suspend_key 'F12'
## A plugin to name your tmux windows smartly.
## https://github.com/ofirgall/tmux-window-name
### Maximum name length of a window
set -g @tmux_window_name_max_name_len "20"
### Replace $HOME with ~ in window names
set -g @tmux_window_name_use_tilde "True"
set -g @tmux_window_name_shells "['bash', 'fish', 'sh', 'zsh', 'oh-my-posh']"
set -g @tmux_window_dir_programs "['nvim', 'vim', 'vi', 'git']"
set -g @tmux_window_name_ignored_programs "['sqlite3', 'x-set-php-aliases', 'oh-my-posh', 'antidot']" # Default is []
set -g @tmux_window_name_substitute_sets "[('.+ipython2', 'ipython2'), ('.+ipython3', 'ipython3'), ('.+\.local', '.local')]"
## https://github.com/tmux-plugins/tmux-continuum
set -g @continuum-restore 'on'
## https://github.com/tmux-plugins/tmux-resurrect
set -g @resurrect-strategy-nvim 'session'
set -g @resurrect-dir '~/.local/state/tmux/tmux-resurrect'
## https://github.com/MunifTanjim/tmux-mode-indicator
set -g @mode_indicator_prefix_mode_style 'bg=default,fg=#7aa2f7'
set -g @mode_indicator_copy_mode_style 'bg=default,fg=yellow'
set -g @mode_indicator_empty_mode_style 'bg=default,fg=#7aa2f7'
set -g @mode_indicator_sync_mode_style 'bg=default,fg=red'
# ╭──────────────────────────────────────────────────────────╮
# │ Plugins │
# ╰──────────────────────────────────────────────────────────╯
run-shell ~/.dotfiles/config/tmux/plugins/tmux-sensible/sensible.tmux
run-shell ~/.dotfiles/config/tmux/plugins/tmux-window-name/tmux_window_name.tmux
run-shell ~/.dotfiles/config/tmux/plugins/tmux-resurrect/resurrect.tmux
run-shell ~/.dotfiles/config/tmux/plugins/tmux-continuum/continuum.tmux
run-shell ~/.dotfiles/config/tmux/plugins/tmux-sessionist/sessionist.tmux
run-shell ~/.dotfiles/config/tmux/plugins/tmux-mode-indicator/mode_indicator.tmux
run-shell ~/.dotfiles/config/tmux/plugins/tmux-suspend/suspend.tmux
run-shell ~/.dotfiles/config/tmux/plugins/tmux-yank/yank.tmux
run-shell ~/.dotfiles/config/tmux/plugins/tmux-current-pane-hostname/current_pane_hostname.tmux
run-shell ~/.dotfiles/config/tmux/plugins/tmux-dark-notify/main.tmux
if-shell "test -e $HOME/.local/state/tmux/tmux-dark-notify-theme.conf" \
"source-file $HOME/.local/state/tmux/tmux-dark-notify-theme.conf"