-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.tmux.conf
195 lines (152 loc) · 6.78 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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
# remap prefix from 'C-b' to 'C-\'
set-option -g prefix 'C-\'
unbind-key C-b
bind-key 'C-\' send-prefix
# disable the repeat
set-option -g repeat-time 0
# start window numbers at 1 to match keyboard order with tmux window order
set-option -g base-index 1
set-window-option -g pane-base-index 1
# renumber windows sequentially after closing any of them
set-option -g renumber-windows on
# auto window rename
set-option -g automatic-rename on
# enable activity alerts
set-window-option -g monitor-activity on
set-option -g visual-activity off
# increase scrollback lines
set-option -g history-limit 50000
# enable clipboard
set-option -g set-clipboard on
# mouse behavior
set-option -g mouse on
# disable escape delay
set-option -sg escape-time 0
# truecolor support
set-option -ga terminal-features ',xterm-256color:RGB'
# default terminal is 256 colors
set-option -g default-terminal 'xterm-256color'
# aggressive resize
set-window-option -g aggressive-resize off
# iTerm2 window name
set-option -g set-titles on
# moving between panes.
bind-key -r h select-pane -L
bind-key -r j select-pane -D
bind-key -r k select-pane -U
bind-key -r l select-pane -R
# resize panes with vim movement keys
bind-key -r H resize-pane -L 5
bind-key -r J resize-pane -D 5
bind-key -r K resize-pane -U 5
bind-key -r L resize-pane -R 5
# remove confirmation questions when closing windows/panes
bind-key x kill-pane
bind-key X kill-pane -a
bind-key & kill-window
# go to last window
bind-key ^ last-window
# splitting panes with current path
bind-key c new-window -c '#{pane_current_path}'
bind-key % split-window -h -c '#{pane_current_path}'
bind-key '"' split-window -v -c '#{pane_current_path}'
# move panes to another window
bind-key M-1 join-pane -t :1
bind-key M-2 join-pane -t :2
bind-key M-3 join-pane -t :3
bind-key M-4 join-pane -t :4
bind-key M-5 join-pane -t :5
bind-key M-6 join-pane -t :6
bind-key M-7 join-pane -t :7
bind-key M-8 join-pane -t :8
bind-key M-9 join-pane -t :9
# Use vim keybindings in copy mode
set-window-option -g mode-keys vi
# Update default binding of `Enter` and `Space to also use copy-pipe
unbind-key -T copy-mode-vi Enter
unbind-key -T copy-mode-vi Space
bind-key -T edit-mode-vi Up send-keys -X history-up
bind-key -T edit-mode-vi Down send-keys -X history-down
# begin selection as in Vim
bind-key -T copy-mode-vi v send-keys -X begin-selection
bind-key -T copy-mode-vi C-v send -X rectangle-toggle
# copy text in copy mode
bind-key -T copy-mode-vi y send -X copy-selection-and-cancel
# translator
bind-key -T copy-mode t send-keys -X copy-pipe-and-cancel "tmux-vocab"
bind-key -T copy-mode-vi t send-keys -X copy-pipe-and-cancel "tmux-vocab"
# run command in split pane / anonther window
bind-key | display-popup -b rounded -d "#{pane_current_path}" -E 'tmux-commands | xargs -r tmux split-window -h -c "#{pane_current_path}"'
bind-key - display-popup -b rounded -d "#{pane_current_path}" -E 'tmux-commands | xargs -r tmux split-window -v -c "#{pane_current_path}"'
bind-key C display-popup -b rounded -d "#{pane_current_path}" -E 'tmux-commands | xargs -r tmux new-window -c "#{pane_current_path}"'
# tmux menu
bind-key A display-menu -x R -y P -T '#[align=centre fg=orange] Commands ' \
'Synchronize Panes' 's' 'set-window-option synchronize-panes' \
'Rename Tab' ',' 'command-prompt -I "#W" { rename-window "%%" }' \
'Run Tmux Command' ':' 'command-prompt'
# project commands
bind-key E display-popup -b rounded -d "#{pane_current_path}" -E 'tmux-project commands | xargs -r tmux-run -t right run --'
# project menu
bind-key R run-shell 'tmux-project -d "#{pane_current_path}" menu'
# grep lines
bind-key G display-popup -b rounded -h 90% -w 85% -x C -y C -d "#{pane_current_path}" -E "tmux-grep | xargs -r tmux-helix open"
# switch pane
bind-key P display-popup -b rounded -T '#[fg=orange]❀ Panes' -E 'tmux-panes'
# switch session
bind-key S display-popup -b rounded -T '#[fg=orange]❀ Sessions' -E 'tmux-sessions'
# popup session
bind-key O if-shell -F '#{==:#{session_name},popup}' {
detach-client
} {
if-shell -F '#{e|==:#{N/s:popup},0}' {
new-session -d -s 'popup' 'tmux source-file ~/.dotfiles/tmux/sessions/popup.tmux.conf'
}
display-popup -b rounded -h 90% -w 85% -E 'tmux attach-session -t popup'
}
# set fish as default shell if available
# install by linux package manager
if-shell 'test -e /bin/zsh' {
set-option -g default-shell /bin/zsh
}
# status bar
set-option -g status on
set-option -g status-interval 1
set-option -g status-position top
set-option -g status-justify left
set-option -g status-style none,fg=#a89984,bg=#3c3836
# status variables format
if-shell 'test "$(uname)" = "Darwin"' {
set-option -g @OS ""
set-option -g @IM " #(defaults read ~/Library/Preferences/com.apple.HIToolbox.plist AppleCurrentKeyboardLayoutInputSourceID | awk -F. '{print $4}' | sed s/PinyinKeyboard/中/)"
set-option -g @CPU " #(iostat -c 2 disk0 | sed '/^\s*$/d' | tail -n 1 | awk '{usage=100-$6} END {print(usage)}' | sed 's/,/./')"
} {
set-option -g @OS ""
set-option -g @IM " #(whoami)#{?SSH_CLIENT,@#h,}"
set-option -g @CPU " #(vmstat 1 2 | tail -1 | awk '{usage=100-$15} END {print(usage)}' | sed 's/,/./')"
}
set-option -g @GIT_BRANCH " #(git -C #{pane_current_path} rev-parse --abbrev-ref HEAD || echo ' ')"
# status bar left
set-option -g status-left-length 100
set-option -g status-left-style none
set-option -g status-left '#[fg=#282828,bg=#a89984,nobold] #{E:@OS} #S #[fg=#a89984,bg=#3c3836,nobold]'
# status bar right
set-option -g status-right-length 150
set-option -g status-right-style none
set-option -g status-right '#[fg=#504945,bg=#3c3836]#[fg=#a89984,bg=#504945] #{E:@CPU}%% #[fg=#3c3836]#[fg=#a89984,bg=#504945] %a %b %d #[fg=#3c3836] #[fg=#a89984,bg=#504945] %H:%M %p #[fg=#3c3836,bg=#504945]#[fg=#a89984,bg=#3c3836]#[fg=#282828,bg=#a89984] #{E:@GIT_BRANCH} #[fg=#3c3836] #[fg=#282828,bg=#a89984]#{E:@IM} '
# window bar style
set-option -g window-status-style 'fg=#3c3836,bg=#504945'
set-option -g window-status-current-style 'fg=#ebdbb2,bg=#49556a'
set-option -g window-status-activity-style 'fg=#3c3836,bg=#504945'
set-option -g window-status-format '#[fg=#3c3836,nobold]#[fg=#a89984] #I: #W #{?window_last_flag, ,}#{?window_activity_flag,#[fg=#d79921] ,}#[fg=#504945,bg=#3c3836,nobold]'
set-option -g window-status-current-format '#[fg=#3c3836,nobold]#[fg=#ebdbb2] #I: #W #[fg=#689d6a]#{?window_zoomed_flag,,} #[fg=#49556a,bg=#3c3836,nobold]'
set-option -g window-status-separator ''
# pane border style
set-option -g pane-active-border-style fg='#fe8019'
set-option -g pane-border-style fg='#3c3836'
# message style
set-option -g message-style none,fg='#fe8010',bg='#504945'
set-option -g message-command-style none,fg='#fe8010',bg='#504945'
# local config
if-shell 'test -e ~/.tmux.conf.local' {
source-file ~/.tmux.conf.local
}