1
0
Files
dotfiles/tmux/.tmux.conf

153 lines
6.1 KiB
Bash

# List of plugins
set -g @plugin 'tmux-plugins/tpm'
###############################################################################
###############################################################################
### general config ###
###############################################################################
###############################################################################
set -g @plugin 'tmux-plugins/tmux-sensible'
bind r source-file ~/.tmux.conf \; display "Reloaded!"
set -sg escape-time 1 # quicker responses
set -g base-index 1 # Numbering of windows
setw -g pane-base-index 1 # Numbering of Panes
set -g mouse on
set-option -gw xterm-keys on
bind-key -n C-t new-window
bind-key -n C-n new-window -c "#{pane_current_path}"
bind '"' split-window -v -c "#{pane_current_path}"
bind % split-window -h -c "#{pane_current_path}"
### set-environment -g PATH "$HOMEBREW_PREFIX/bin:$PATH"
bind o run-shell '\
SID="scratch-#{window_id}"; \
if ! tmux has-session -t "$SID" 2>/dev/null; then \
tmux new-session -d -s "$SID" -c "#{pane_current_path}"; \
fi; \
tmux popup -d "#{pane_current_path}" -w 66% -h 66% -E "tmux attach-session -t \"$SID\""'
# set -ga terminal-overrides ',*:Ss=\E[%p1%d q:Se=\E[2 q'
bind-key -n C-S-Down next-window
bind-key -n C-S-Up previous-window
bind-key -n C-S-Left swap-window -t -1\; select-window -t -1
bind-key -n C-S-Right swap-window -t +1\; select-window -t +1
setw -g mode-keys vi
bind-key -T copy-mode-vi v send-keys -X begin-selection
bind-key -T copy-mode-vi y send-keys -X copy-selection
set -g set-clipboard on
set -g focus-events on
# Increase scrollback buffer size
set -g history-limit 50000
# Improve terminal scrolling
set -ga terminal-overrides ',*:smcup@:rmcup@'
set-option -g default-shell $SHELL
set-option -g allow-rename off
set-option -sa terminal-features ',alacritty:RGB'
set-option -ga terminal-features ",alacritty:usstyle"
set-option -ga terminal-overrides ',alacritty:Tc'
if-shell 'infocmp tmux-256color >/dev/null 2>&1' {
set -g default-terminal "tmux-256color"
} {
set -g default-terminal "tmux"
}
###############################################################################
###############################################################################
### theme and misc plugins ###
###############################################################################
###############################################################################
set -g @plugin 'rose-pine/tmux'
set -g @rose_pine_variant 'main' # Options are 'main', 'moon' or 'dawn'
set -g @rose_pine_date_time '%Y-%m-%d %H:%M '
set -g @rose_pine_directory 'on'
set -g @rose_pine_disable_active_window_menu 'off'
#set -g @rose_pine_left_separator ' > ' # The strings to use as separators are 1-space padded
#set -g @rose_pine_right_separator ' < ' # Accepts both normal chars & nerdfont icons
#set -g @rose_pine_field_separator ' ' # Default is two-space-padded, but can be set to anything
set -g @plugin 'MunifTanjim/tmux-mode-indicator'
set -g @rose_pine_status_left_prepend_section '#{tmux_mode_indicator} '
# bind F5 to theme switch
bind-key . run-shell 'zsh -c "$DOTFILES/scripts/hcf/rose_pine_switch"'
set -g @plugin 'ofirgall/tmux-window-name'
# Replace login shell argv (-l/--login) so window name shows directory instead of "--login"
set -g @tmux_window_name_substitute_sets "[('.+bash', 'bash'), ('cbonsai.+', 'cbonsai'), (r'^(-l|--login)$', '')]"
# Include Homebrew zsh path so the plugin recognizes it as a shell (otherwise it shows full path or '-')
set -g @tmux_window_name_shells "['bash', 'fish', 'sh', 'zsh', '/opt/homebrew/bin/zsh', '/usr/local/bin/zsh']"
# When pane_current_path is unset tmux may show '-'; show '~' instead
set -g @tmux_window_name_dir_substitute_sets "[(r'^-$', '~'), (r'^\\.$', '~')]"
set -g @tmux_window_dir_programs "['nvim', 'vim', 'vi', 'git', 'cbonsai']"
set -g @tmux_window_name_use_tilde "True"
set -g @tmux_window_name_max_name_len "100"
set -g @plugin 'tmux-plugins/tmux-open'
set -g @plugin 'pschmitt/tmux-ssh-split'
set-option -g @ssh-split-keep-cwd "true"
set-option -g @ssh-split-keep-remote-cwd "true"
set-option -g @ssh-split-fail "true"
set-option -g @ssh-split-no-env "false"
set-option -g @ssh-split-no-shell "false"
set-option -g @ssh-split-strip-cmd "true"
set-option -g @ssh-split-verbose "true"
set-option -g @ssh-split-debug "false"
set-option -g @ssh-split-h-key "V"
set-option -g @ssh-split-v-key 'H'
set-option -g @ssh-split-w-key "N"
set-option -g @ssh-split-r-key "R"
set -g @plugin 'Morantron/tmux-fingers'
###############################################################################
###############################################################################
### Nvim-tmux-navigation setup ###
###############################################################################
###############################################################################
# decide whether we're in a Vim process
is_vim="~/.is_vim.sh '#{pane_tty}'"
bind-key -n 'S-Left' if-shell "$is_vim" 'send-keys S-Left' 'select-pane -L'
bind-key -n 'S-Down' if-shell "$is_vim" 'send-keys S-Down' 'select-pane -D'
bind-key -n 'S-Up' if-shell "$is_vim" 'send-keys S-Up' 'select-pane -U'
bind-key -n 'S-Right' if-shell "$is_vim" 'send-keys S-Right' '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 -n 'C-Space' if-shell "$is_vim" 'send-keys C-Space' 'select-pane -t:.+'
bind-key -T copy-mode-vi 'S-Left' select-pane -L
bind-key -T copy-mode-vi 'S-Down' select-pane -D
bind-key -T copy-mode-vi 'S-Up' select-pane -U
bind-key -T copy-mode-vi 'S-Right' select-pane -R
bind-key -T copy-mode-vi 'C-\' select-pane -l
bind-key -T copy-mode-vi 'C-Space' select-pane -t:.+
run '~/.tmux/plugins/tpm/tpm'