-
Notifications
You must be signed in to change notification settings - Fork 3
/
tmux.conf
174 lines (148 loc) · 6.63 KB
/
tmux.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# vim: set tabstop=2 shiftwidth=2 foldmethod=marker:
# plugins {{{
set -g @plugin 'https://github.com/tmux-plugins/tmux-copycat'
set -g @plugin 'https://github.com/tmux-plugins/tmux-open'
set -g @plugin 'https://github.com/tmux-plugins/tmux-resurrect'
set -g @plugin 'https://github.com/tmux-plugins/tmux-continuum'
set -g @plugin 'https://github.com/tmux-plugins/tmux-prefix-highlight'
set -g @resurrect-strategy-nvim 'session'
set -g @continuum-restore 'on'
set -g @continuum-save-interval '30'
# }}}
# globals {{{
set -g default-terminal "tmux-256color"
set -as terminal-overrides ",screen*:Tc,xterm*:Tc"
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix
set -g base-index 1
set -g escape-time 10
set -g history-limit 100000
set -g focus-events on
# tmux-open
set -g @open-S "https://duckduckgo.com/?q="
# keep session alive when last window closes
set -g remain-on-exit off
# Renumber windows on closing a pane
set -g renumber-windows on
# }}}
# status bar {{{
set-option -g status-position bottom
set -g status-left-length 40
set -g @prefix_highlight_show_copy_mode 'on'
# TokyoNight colors for Tmux
set -g mode-style "fg=#7aa2f7,bg=#3b4261"
set -g message-style "fg=#7aa2f7,bg=#3b4261"
set -g message-command-style "fg=#7aa2f7,bg=#3b4261"
set -g pane-border-style "fg=#3b4261"
set -g pane-active-border-style "fg=#7aa2f7"
set -g status "on"
set -g status-justify "left"
set -g status-style "fg=#7aa2f7,bg=#1f2335"
set -g status-left-length "100"
set -g status-right-length "100"
set -g status-left-style NONE
set -g status-right-style NONE
set -g status-left "#[fg=#15161E,bg=#7aa2f7,bold] #S #[fg=#7aa2f7,bg=#1f2335,nobold,nounderscore,noitalics]"
set -g status-right "#[fg=#1f2335,bg=#1f2335,nobold,nounderscore,noitalics]#[fg=#7aa2f7,bg=#1f2335] #{prefix_highlight} #[fg=#3b4261,bg=#1f2335,nobold,nounderscore,noitalics]#[fg=#7aa2f7,bg=#3b4261] %Y-%m-%d %I:%M %p #[fg=#7aa2f7,bg=#3b4261,nobold,nounderscore,noitalics]#[fg=#15161E,bg=#7aa2f7,bold] #h "
setw -g window-status-activity-style "underscore,fg=#a9b1d6,bg=#1f2335"
setw -g window-status-separator ""
setw -g window-status-style "NONE,fg=#a9b1d6,bg=#1f2335"
setw -g window-status-format "#[fg=#1f2335,bg=#1f2335,nobold,nounderscore,noitalics]#[default] #I #W #F #[fg=#1f2335,bg=#1f2335,nobold,nounderscore,noitalics]"
setw -g window-status-current-format "#[fg=#1f2335,bg=#3b4261,nobold,nounderscore,noitalics]#[fg=#7aa2f7,bg=#3b4261,bold] #I #W #F #[fg=#3b4261,bg=#1f2335,nobold,nounderscore,noitalics]"
# Make it obvious which is the active window in the status line
set-window-option -g window-status-current-style bg=blue
# }}}
# copy & paste {{{
set-window-option -g mode-keys vi
set -g mouse on
set-option -s set-clipboard on
bind p run "tmux set-buffer \"$(xclip -o)\"; tmux paste-buffer"
bind-key -T copy-mode-vi v send-keys -X begin-selection
bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel 'xclip -in -selection clipboard'
bind -T copy-mode-vi space send-keys -X copy-pipe-and-cancel 'xclip -in -selection clipboard'
bind -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel 'xclip -in -selection clipboard'
bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe 'xclip -se c -i'
# Double LMB Select & Copy (Word)
# https://stackoverflow.com/a/46638561/777247
bind-key -n DoubleClick1Pane \
select-pane \; \
copy-mode -M \; \
send-keys -X select-word \; \
run-shell "sleep .2s" \; \
send-keys -X copy-pipe-and-cancel "xclip -in -selection clipboard"
# Middle click to paste from the primary buffer
unbind-key MouseDown2Pane
bind-key -n MouseDown2Pane run "tmux set-buffer \"$(xclip -o)\"; tmux paste-buffer"
# WSL variants of the above
if-shell -b 'test -n "$WSLENV"' {
bind p run "tmux set-buffer \"$(powershell.exe Get-Clipboard)\"; tmux paste-buffer"
bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel 'clip.exe'
bind -T copy-mode-vi space send-keys -X copy-pipe-and-cancel 'clip.exe'
bind -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel 'clip.exe'
bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe 'clip.exe'
bind-key -n MouseDown2Pane run "tmux set-buffer \"$(powershell.exe Get-Clipboard)\"; tmux paste-buffer"
bind-key -n DoubleClick1Pane \
select-pane \; \
copy-mode -M \; \
send-keys -X select-word \; \
run-shell "sleep .2s" \; \
send-keys -X copy-pipe-and-cancel "clip.exe"
}
# }}}
# mappings {{{
bind r source-file ~/.tmux.conf \; display-message "config reloaded"
# smart pane switching with awareness of Vim splits (vim-tmux-navigator)
is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
| grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|l?n?vim?x?|fzf)(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'
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
# switch windows with alt+number
bind-key -n M-1 select-window -t 1
bind-key -n M-2 select-window -t 2
bind-key -n M-3 select-window -t 3
bind-key -n M-4 select-window -t 4
bind-key -n M-5 select-window -t 5
bind-key -n M-6 select-window -t 6
bind-key -n M-[ select-window -t 6
bind-key -n M-7 select-window -t 7
bind-key -n M-8 select-window -t 8
bind-key -n M-9 select-window -t 9
# swap windows with alt-shift-left/right
bind-key -n M-H swap-window -t -1\; select-window -t -1
bind-key -n M-L swap-window -t +1\; select-window -t +1
# resizing of panes
bind -n S-Left resize-pane -L 2
bind -n S-Right resize-pane -R 2
bind -n S-Down resize-pane -D 1
bind -n S-Up resize-pane -U 1
bind -n C-Left resize-pane -L 10
bind -n C-Right resize-pane -R 10
bind -n C-Down resize-pane -D 5
bind -n C-Up resize-pane -U 5
# prefix + hjkl to switch
bind -r h select-pane -L
bind -r j select-pane -D
bind -r k select-pane -U
bind -r l select-pane -R
# prefix + C-hjkl to create
bind C-h split-window -h -c "#{pane_current_path}"
bind C-j split-window -v -c "#{pane_current_path}"
bind C-k split-window -v -c "#{pane_current_path}"
bind C-l split-window -h -c "#{pane_current_path}"
bind c new-window -c "#{pane_current_path}"
# TODO: add a notes mapping (maybe upgrade tmux for floating window)
# open vimrc, close when vim exits
bind V split-window -h -c "~/dev/dotfiles" "v ~/dev/dotfiles/vimrc"
# Sync panes
bind-key X set-window-option synchronize-panes\; display-message "synchronize-panes: #{?pane_synchronized,on,off}"
unbind-key -n DoubleClick1Status
# }}}
run '~/.tmux/plugins/tpm/tpm'