Files
dotfiles/.config/tmux/tmux.conf
T
2024-11-08 11:20:25 -05:00

128 lines
4.9 KiB
Bash

# ~/.config/tmux/tmux.conf
set -g escape-time 0
set -g default-terminal "tmux-256color"
set -ag terminal-overrides ",xterm-256color:RGB"
set -g history-limit 150000
set -g display-time 3000
set -g status-interval 5
set -g focus-events on
set -g status-position top
# Start indexes at 1 instead of 0
set -g base-index 1
setw -g pane-base-index 1
set -g renumber-windows on
# Set term title to current session window
set -g set-titles on
set -g set-titles-string "#I: #W"
# Change activation from ctrl+b to ctrl+a
set -g prefix C-a
unbind C-b
bind-key C-a send-prefix
# Split windows with | and -
unbind %
bind-key -N "Add a new pane to the right of the currently active pane" | split-window -h -c "#{pane_current_path}"
unbind '"'
bind-key -N "Add a new pane under the currently active pane" - split-window -v -c "#{pane_current_path}"
# Reload config
unbind R
bind-key -N "Reload tmux configuration" R source-file ~/.config/tmux/tmux.conf \; display "Config reloaded."
# Pane navigation
bind-key -N "Navigate one pane to the left" -n C-h select-pane -L
bind-key -N "Navigate one pane down" -n C-j select-pane -D
bind-key -N "Navigate one pane up" -n C-k select-pane -U
bind-key -N "Navigate one pane to the right" -n C-l select-pane -R
# Resize panes
bind-key -N "Resize pane left" -r h resize-pane -L 5
bind-key -N "Resize pane down" -r j resize-pane -D 5
bind-key -N "Resize pane up" -r k resize-pane -U 5
bind-key -N "Resize pane right" -r l resize-pane -R 5
# Fullscreen current pane
bind-key -N "Zoom current pane (fill window)" -r m resize-pane -Z
# create new windows in the same cwd
bind-key -N "Create a new window within CWD" c new-window -c "#{pane_current_path}"
# Window navigation
bind-key -N "Move to previous window" -n C-p previous-window
bind-key -N "Move to next window" -n C-n next-window
# Prompt to rename new windows on creation
set-hook -g after-new-window 'command-prompt -I "#{window_pane}" "rename-window '%%'"'
set -g mouse on
setw -g mode-keys vi
setw -g status-keys vi
unbind -T copy-mode-vi Space;
unbind -T copy-mode-vi Enter;
bind-key -N "Begin selection" -T copy-mode-vi 'v' send -X begin-selection
bind-key -N "Copy selection to buffer" -T copy-mode-vi 'y' send -X copy-selection
unbind -T copy-mode-vi MouseDragEnd1Pane
##########################
# Plugins
##########################
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'christoomey/vim-tmux-navigator'
set -g @plugin 'nordtheme/tmux'
set -g @plugin 'tmux-plugins/tmux-yank'
set -g @plugin 'tmux-plugins/tmux-resurrect' # persist tmux sessions across reboot
set -g @plugin 'tmux-plugins/tmux-continuum' # automatically saves session every 15 mins
set -g @plugin 'laktak/extrakto' # fzf search in tmux (prefix+tab)
set -g @plugin 'sainnhe/tmux-fzf' # <prefix> F
set -g @plugin 'alexwforsythe/tmux-which-key' # <prefix><space>
set -g @plugin 'niqodea/tmux-matryoshka' # nested tmux (def F1-F3)
# Session restore options
set -g @continuum-boot 'off' # automatically start tmux session on boot
set -g @continuum-boot-options 'alacritty,fullscreen' # start tmux in fullscreen alacritty on macOS
set -g @continuum-restore 'on'
set -g @resurrect-strategy-nvim 'session'
set -g @resurrect-capture-pane-contents 'on'
set -g @resurrect-processes 'ssh nvim man less tail btop htop vi vim' # space separated list of programs to restore
set -g @matryoshka_down_keybind 'M-d' # keybind to disable outer-most active tmux
set -g @matryoshka_up_keybind 'M-e' # keybind to enable inner-most inactive tmux
set -g @matryoshka_up_recursive_keybind 'M-U' # keybind to recursively enable all tmux instances
set -g @matryoshka_inactive_status_style 'fg=default,bg=brightblack' # TODO: Try to make this look better..
# set -g @matryoshka_status_style_option 'my-status-style'
# use fzf to switch sessions
unbind s
bind-key -N "Attach to another session" s run-shell -b "$HOME/.config/tmux/plugins/tmux-fzf/scripts/session.sh switch"
# use fzf to switch windows
unbind w
bind-key -N "Switch to another window (works across any session)" w run-shell -b "$HOME/.config/tmux/plugins/tmux-fzf/scripts/window.sh switch"
##### FZF settings
TMUX_FZF_SESSION_FORMAT="#{session_windows} windows"
bind-key -N "User FZF menu" M run-shell -b "$HOME/.config/tmux/plugins/tmux-fzf/scripts/menu.sh"
# needs 1 or 3+ entries.
TMUX_FZF_MENU=\
"rename window\n$HOME/.config/tmux/plugins/tmux-fzf/scripts/window.sh rename\n"\
"switch session\n$HOME/.config/tmux/plugins/tmux-fzf/scripts/session.sh switch\n"\
"change pane layout\n$HOME/.config/tmux/plugins/tmux-fzf/scripts/pane.sh layout\n"\
"break out pane\n$HOME/.config/tmux/plugins/tmux-fzf/scripts/pane.sh break\n"\
"join pane\n$HOME/.config/tmux/plugins/tmux-fzf/scripts/pane.sh join\n"\
"session options\n$HOME/.config/tmux/plugins/tmux-fzf/scripts/session.sh\n"\
"window options\n$HOME/.config/tmux/plugins/tmux-fzf/scripts/window.sh\n"\
"pane options\n$HOME/.config/tmux/plugins/tmux-fzf/scripts/pane.sh\n"
run '~/.config/tmux/plugins/tpm/tpm'