From 4d284994232e2556aa4dfe5aded61ab1cca51cff Mon Sep 17 00:00:00 2001 From: Ismo Vuorinen Date: Tue, 7 Jan 2025 15:55:19 +0200 Subject: [PATCH] chore(config): tmux config tweaks - undercurl support - underscore colors - nvim split aware moving - detach-on-destroy off - session name display in status-right - escape-time to zero - default terminal to use $TERM --- config/tmux/tmux.conf | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/config/tmux/tmux.conf b/config/tmux/tmux.conf index 7cd6454..ecfa86b 100644 --- a/config/tmux/tmux.conf +++ b/config/tmux/tmux.conf @@ -25,6 +25,13 @@ bind -n M-Right select-pane -R bind -n M-Up select-pane -U bind -n M-Down select-pane -D +# Smart pane switching with awareness of vim splits +is_vim='echo "#{pane_current_command}" | grep -iqE "(^|\/)g?(view|n?vim?)(diff)?$"' +bind -n C-h if-shell "$is_vim" "send-keys C-h" "select-pane -L" +bind -n C-j if-shell "$is_vim" "send-keys C-j" "select-pane -D" +bind -n C-k if-shell "$is_vim" "send-keys C-k" "select-pane -U" +bind -n C-l if-shell "$is_vim" "send-keys C-l" "select-pane -R" + # Reload tmux config with + r bind r source-file ~/.dotfiles/config/tmux/tmux.conf \; display "tmux cfg reloaded!" @@ -70,8 +77,13 @@ bind p paste-buffer # │ Settings │ # ╰──────────────────────────────────────────────────────────╯ -set -g default-terminal "tmux-256color" -set -ag terminal-overrides ",xterm-256color:RGB" +# Undercurl +set -g default-terminal "${TERM}" +set -as terminal-overrides ',*:Smulx=\E[4::%p1%dm' # undercurl support +set -as terminal-overrides ',*:Setulc=\E[58::2::::%p1%{65536}%/%d::%p1%{256}%/%{255}%&%d::%p1%{255}%&%d%;m' # underscore colors - needs tmux-3.0 + +# set -g default-terminal "tmux-256color" +# set -ag terminal-overrides ",xterm-256color:RGB" # Setting status on set -g status "on" @@ -108,6 +120,12 @@ set-option -g renumber-windows on # set vi-mode set-window-option -g mode-keys vi +# don't detach tmux when killing a session +set -g detach-on-destroy off + +# address vim mode switching delay (http://superuser.com/a/252717/65504) +set -s escape-time 0 + # ╭──────────────────────────────────────────────────────────╮ # │ Theme │ # ╰──────────────────────────────────────────────────────────╯ @@ -121,7 +139,7 @@ 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}/#(tms sessions) #{tmux_mode_indicator}" +set-option -g status-right "#S@#{hostname_short} #{tmux_mode_indicator}" set -g pane-border-style "fg=#3b4261" set -g pane-active-border-style "fg=#7aa2f7"