Xinqi Bao's Git

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