Xinqi Bao's Git

refactor(tmux): reorganize config and enable mouse support
[dotfiles.git] / .tmux.conf
1 # Terminal and colors
2 set -g default-terminal 'xterm-256color'
3
4 # General settings
5 set -g history-limit 10000
6 set -g mouse on
7 set -g escape-time 0
8 set -g focus-events on
9
10 # Remap prefix from C-b to C-a
11 unbind C-b
12 set -g prefix C-a
13 bind C-a send-prefix
14
15 # Window and pane management
16 bind c new-window -c ${HOME}
17 bind | split-window -h -c "#{pane_current_path}"
18 bind - split-window -v -c "#{pane_current_path}"
19 bind C-a last-window
20 unbind '"'
21 unbind %
22
23 # Status bar
24 set -g status-position bottom
25 set -g status-justify left
26 set -g status-interval 2
27 set -g status-style fg=colour137,bg=colour234,dim
28 set -g status-left ''
29 set -g status-left-length 20
30 set -g status-right '#[fg=colour233,bg=colour245,bold] %H:%M #[fg=colour233,bg=colour253,bold] %m-%d '
31 set -g status-right-length 50
32
33 # Window status
34 setw -g window-status-current-style fg=colour69,bg=colour253,bold
35 setw -g window-status-current-format ' #I#[fg=colour250]:#[fg=colour233]#W#[fg=colour69]#F '
36 setw -g window-status-style fg=colour131,bg=colour245,none
37 setw -g window-status-format ' #I#[fg=colour237]:#[fg=colour233]#W#[fg=colour131]#F '
38 setw -g window-status-bell-style fg=colour255,bg=colour1,bold
39
40 # Pane borders
41 set -g pane-border-style fg=colour238,bg=colour235
42 set -g pane-active-border-style fg=colour51,bg=colour236
43
44 # Messages
45 set -g message-style fg=colour232,bg=colour166,bold
46 set -g message-command-style fg=blue,bg=black
47
48 # Clock mode
49 setw -g clock-mode-colour colour135
50 setw -g mode-style fg=colour196,bg=colour238,bold
51
52 # Quiet mode
53 set -g visual-activity off
54 set -g visual-bell off
55 set -g visual-silence off
56 set -g bell-action none
57 setw -g monitor-activity off
58
59 # Reload config
60 bind r source-file ~/.tmux.conf \; display-message "Config reloaded"
61
62 # Vim-tmux-navigator: smart pane switching with vim awareness
63 # https://github.com/christoomey/vim-tmux-navigator
64 is_vim="ps -o state= -o comm= -t '#{pane_tty}' | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"
65 bind -n 'C-h' if-shell "$is_vim" 'send-keys C-h' 'select-pane -L'
66 bind -n 'C-j' if-shell "$is_vim" 'send-keys C-j' 'select-pane -D'
67 bind -n 'C-k' if-shell "$is_vim" 'send-keys C-k' 'select-pane -U'
68 bind -n 'C-l' if-shell "$is_vim" 'send-keys C-l' 'select-pane -R'
69 bind -n 'C-\' if-shell "$is_vim" 'send-keys C-\\' 'select-pane -l'
70
71 bind -T copy-mode-vi 'C-h' select-pane -L
72 bind -T copy-mode-vi 'C-j' select-pane -D
73 bind -T copy-mode-vi 'C-k' select-pane -U
74 bind -T copy-mode-vi 'C-l' select-pane -R
75 bind -T copy-mode-vi 'C-\' select-pane -l