Xinqi Bao's Git

refactor(tmux): reorganize config and enable mouse support
[dotfiles.git] / .tmux.conf
index 29d1312..4aa3ac0 100644 (file)
@@ -1,94 +1,75 @@
-# Improve colours
-set -g default-terminal 'xterm-256colour'
+# Terminal and colors
+set -g default-terminal 'xterm-256color'
 
-# Set scrollback buffer to 10000
+# General settings
 set -g history-limit 10000
+set -g mouse on
+set -g escape-time 0
+set -g focus-events on
 
-# remap prefix from 'C-b' to 'C-z'
+# Remap prefix from C-b to C-a
 unbind C-b
-set-option -g prefix C-a
-bind-key C-a send-prefix
+set -g prefix C-a
+bind C-a send-prefix
 
-# split panes using | and -
-bind c new-window      -c $HOME
+# Window and pane management
+bind c new-window      -c ${HOME}
 bind | split-window -h -c "#{pane_current_path}"
 bind - split-window -v -c "#{pane_current_path}"
-bind-key C-a last-window
+bind C-a last-window
 unbind '"'
 unbind %
 
-## Status bar design
-# status line
+# Status bar
+set -g status-position bottom
 set -g status-justify left
 set -g status-interval 2
-
-# loud or quiet?
-set-option -g visual-activity off
-set-option -g visual-bell off
-set-option -g visual-silence off
-set-window-option -g monitor-activity off
-set-option -g bell-action none
-
-set -g default-terminal "screen-256colour"
-
-
-# The modes {
-setw -g clock-mode-colour colour135
-setw -g mode-style fg=colour196,bg=colour238,bold
-# }
-
-
-# The panes {
-set -g pane-border-style fg=colour238,bg=colour235
-set -g pane-active-border-style fg=colour51,bg=colour236
-# }
-
-
-# The statusbar {
-set -g status-position bottom
 set -g status-style fg=colour137,bg=colour234,dim
-
 set -g status-left ''
 set -g status-left-length 20
-
 set -g status-right '#[fg=colour233,bg=colour245,bold] %H:%M #[fg=colour233,bg=colour253,bold] %m-%d '
 set -g status-right-length 50
 
+# Window status
 setw -g window-status-current-style fg=colour69,bg=colour253,bold
 setw -g window-status-current-format ' #I#[fg=colour250]:#[fg=colour233]#W#[fg=colour69]#F '
-
 setw -g window-status-style fg=colour131,bg=colour245,none
 setw -g window-status-format ' #I#[fg=colour237]:#[fg=colour233]#W#[fg=colour131]#F '
-
 setw -g window-status-bell-style fg=colour255,bg=colour1,bold
-# }
 
+# Pane borders
+set -g pane-border-style fg=colour238,bg=colour235
+set -g pane-active-border-style fg=colour51,bg=colour236
 
-# The messages {
+# Messages
 set -g message-style fg=colour232,bg=colour166,bold
 set -g message-command-style fg=blue,bg=black
-# }
-
-# Smart pane switching with awareness of Vim splits.
-# See: https://github.com/christoomey/vim-tmux-navigator{
-is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
-    | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"
-bind-key -n 'C-h' if-shell "$is_vim" 'send-keys C-h'  'select-pane -L'
-bind-key -n 'C-j' if-shell "$is_vim" 'send-keys C-j'  'select-pane -D'
-bind-key -n 'C-k' if-shell "$is_vim" 'send-keys C-k'  'select-pane -U'
-bind-key -n 'C-l' if-shell "$is_vim" 'send-keys C-l'  '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 -T copy-mode-vi 'C-h' select-pane -L
-bind-key -T copy-mode-vi 'C-j' select-pane -D
-bind-key -T copy-mode-vi 'C-k' select-pane -U
-bind-key -T copy-mode-vi 'C-l' select-pane -R
-bind-key -T copy-mode-vi 'C-\' select-pane -l
-# }
+# Clock mode
+setw -g clock-mode-colour colour135
+setw -g mode-style fg=colour196,bg=colour238,bold
 
-#enable powerline for tmux
-#source /usr/lib/python3.8/site-packages/powerline/bindings/tmux/powerline.conf
+# Quiet mode
+set -g visual-activity off
+set -g visual-bell off
+set -g visual-silence off
+set -g bell-action none
+setw -g monitor-activity off
+
+# Reload config
+bind r source-file ~/.tmux.conf \; display-message "Config reloaded"
+
+# Vim-tmux-navigator: smart pane switching with vim awareness
+# https://github.com/christoomey/vim-tmux-navigator
+is_vim="ps -o state= -o comm= -t '#{pane_tty}' | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(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'
+bind -n 'C-\' if-shell "$is_vim" 'send-keys C-\\' 'select-pane -l'
+
+bind -T copy-mode-vi 'C-h' select-pane -L
+bind -T copy-mode-vi 'C-j' select-pane -D
+bind -T copy-mode-vi 'C-k' select-pane -U
+bind -T copy-mode-vi 'C-l' select-pane -R
+bind -T copy-mode-vi 'C-\' select-pane -l