From 885fee93cb48375b8cbd7949e9603a4298de6e0c Mon Sep 17 00:00:00 2001 From: 434b <17012133+0xricksanchez@users.noreply.github.com> Date: Sun, 10 Sep 2023 18:28:15 +0200 Subject: [PATCH] chore: update tmux (#144) --- .tmux.conf | 187 +++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 147 insertions(+), 40 deletions(-) diff --git a/.tmux.conf b/.tmux.conf index 28a2980..e0dfbb1 100644 --- a/.tmux.conf +++ b/.tmux.conf @@ -1,7 +1,12 @@ +#-------------------------------------------------------------------------- +# Configuration +#-------------------------------------------------------------------------- + # Unbind CTRL-b for tmux control # Set it to CTRL-s # -> CTRL-a is needed to kill the QEMU instance # -> CTRL-b is necessary in VIM +unbind C-a unbind C-b set -g prefix C-s @@ -10,57 +15,159 @@ set -g prefix C-s # client connected to *that window*. Much more reasonable. setw -g aggressive-resize on -# Hot reloading tmux.conf with CTRL-A + r -bind r source-file ./.tmux.conf - -# Extend history -set -g history-limit 200000 - -# Enable color support -set -g default-terminal 'xterm-256color' - # Modify pane control to allow Alt+ 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 -# Enable mouse controls +# Highlight selected window +setw -g window-status-current-style bg=red + +# Use Vi mode +setw -g mode-keys vi + +# Increase scrollback buffer size +set -g history-limit 200000 + +# Allow automatic renaming of windows +set -g allow-rename on +bind v command-prompt -p "rename window" "rename-window '%%'" +unbind -n C-r +set -g automatic-rename off + +# Renumber windows when one is removed. +set -g renumber-windows on + +# Improve colors +set -g default-terminal "${TERM}" + +# Enable undercurl +set -as terminal-overrides ',*:Smulx=\E[4::%p1%dm' + +# Enable undercurl colors +set -as terminal-overrides ',*:Setulc=\E[58::2::%p1%{65536}%/%d::%p1%{256}%/%{255}%&%d::%p1%{255}%&%d%;m' + +# Use 24bit colors +set-option -sa terminal-overrides ",xterm*:Tc" + +# Allow the mouse to resize windows and select tabs set -g mouse on -# Enable activity monitor, which can help if many tmux sessions are active +# Allow tmux to set the terminal title +set -g set-titles on + +# Monitor window activity to display in the status bar setw -g monitor-activity on -set -g visual-activity on -# Highlight selected window -setw -g window-status-current-style bg=red +# A bell in another window should cause a bell in the current window +set -g bell-action any -# Highlight selected pane -set -g pane-active-border-style fg=colour166 -set -g pane-border-style fg=colour235 #fg=base02 +# Don't show distracting notifications +set -g visual-bell off +set -g visual-activity off -# No automatic renaming of windows -set -g allow-rename off +# Focus events enabled for terminals that support them +set -g focus-events on -# No bell -set -g bell-action none -set -g visual-bell off +# 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 + +#-------------------------------------------------------------------------- +# Status line +#-------------------------------------------------------------------------- + +# Status line customisation +set-option -g status-left-length 100 +# set-option -g status-right-length 100 +set-option -g status-left " #{session_name} " +# set-option -g status-right "#{pane_title} " + +# set-option -g status-style "fg=#7C7D83 bg=#18242e" # ayu +# set-option -g status-style "fg=#7C7D83 bg=#16151d" # tokyo night +# set-option -g status-style "fg=#7C7D83 bg=#24282f" # one dark +# set-option -g status-style "fg=#7C7D83 bg=#272727" # gruvbox dark +set-option -g status-style "fg=#7C7D83 bg=default" # default will set the background to transparent + +set-option -g window-status-format "#{window_index}:#{window_name}#{window_flags} " # window_name -> pane_current_command +set-option -g window-status-current-format "#{window_index}:#{window_name}#{window_flags} " +set-option -g window-status-current-style "fg=#dcc7a0" +set-option -g window-status-activity-style none + +#-------------------------------------------------------------------------- +# Key Bindings +#-------------------------------------------------------------------------- + +# -r means that the bind can repeat without entering prefix again +# -n means that the bind doesn't use the prefix + +# Send prefix to a nested tmux session by doubling the prefix +bind C-a send-prefix + +# 'PREFIX r' to reload of the config file +unbind r +bind r source-file ./.tmux.conf\; display-message '~/.tmux.conf reloaded' + +# Allow holding Ctrl when using using prefix+p/n for switching windows +bind C-p previous-window +bind C-n next-window + +# Move around panes like in vim +bind -r h select-pane -L +bind -r j select-pane -D +bind -r k select-pane -U +bind -r l select-pane -R +bind -r C-h select-window -t :- +bind -r C-l select-window -t :+ + +# 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" + +# Switch between previous and next windows with repeatable +bind -r n next-window +bind -r p previous-window + +# Move the current window to the next window or previous window position +bind -r N run-shell "tmux swap-window -t $(expr $(tmux list-windows | grep \"(active)\" | cut -d \":\" -f 1) + 1)" +bind -r P run-shell "tmux swap-window -t $(expr $(tmux list-windows | grep \"(active)\" | cut -d \":\" -f 1) - 1)" + +# Switch between two most recently used windows +bind Space last-window + +# switch between two most recently used sessions +bind b switch-client -l + +# use prefix+| (or prefix+\) to split window horizontally and prefix+- or +# (prefix+_) to split vertically also use the current pane path to define the +# new pane path +bind | split-window -h -c "#{pane_current_path}" +bind - split-window -v -c "#{pane_current_path}" + +# change the path for newly created windows +bind c new-window -c "#{pane_current_path}" + +# Rebind clear screen +bind -n C-l send-keys C-l + +# window with a list of sessions to switch to +bind y run -b "tmux show-buffer | xclip -selection clipboard"\; display-message "copied tmux buffer to system clipboard" + +set -g @plugin 'tmux-plugins/tpm' +set -g @plugin 'tmux-plugins/tmux-sensible' +set -g @plugin 'tmux-plugins/tmux-continuum' +set -g @catppuccin_flavour 'mocha' +set -g @catppuccin_transparent_background 'true' +set -g @plugin 'dreamsofcode-io/catppuccin-tmux' +set -g @plugin 'christoomey/vim-tmux-navigator' +set -g @plugin 'tmux-plugins/tmux-yank' -# Set color for active window -setw -g window-status-current-style fg=colour166,bg=default,bright # fg=orange -setw -g window-status-style fg=colour144,bg=default,dim # fg=base0 - -# Remove asterisk and modify how active window is highlighted -#set -g window-status-current-style "underscore" -setw -g window-status-current-format '[ #I #W ]' -setw -g window-status-format '#I #W' - -# statusbar -set -g status-style bg=colour235,fg=colour166 # bg=base02, fg=orange -set -g status-left-length 20 -set -g status-left '' -set -g status-right-length 50 -set -g status-right '#[fg=colour166]:: %d %b %Y #[fg=colour166]:: %l:%M %p' -set -g status-position top -set -g status-interval 5 -set -g status-justify left +# git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm +# Run + I to install plugins +run '~/.tmux/plugins/tpm/tpm'