-
Notifications
You must be signed in to change notification settings - Fork 0
/
tmux.conf
211 lines (164 loc) · 8.11 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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
# improve colors
set -g default-terminal 'screen-256color'
# Reload config
bind-key r source-file ~/.tmux.conf \; display-message "~/.tmux.conf reloaded"
# act like vim
setw -g mode-keys vi
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
bind-key -r C-h select-window -t :-
bind-key -r C-l select-window -t :+
# act like GNU screen
unbind C-b
set -g prefix C-A
bind C-A send-prefix
# start window numbers at 1 to match keyboard order with tmux window order
set -g base-index 1
set-window-option -g pane-base-index 1
# renumber windows sequentially after closing any of them
set -g renumber-windows on
# increase scrollback lines
set -g history-limit 10000
# clear history
bind -n C-b send-keys -R \; clear-history \; send-keys C-l
# switch to last pane
bind-key C-Space last-pane
# create new session from current path
bind-key C-b send-keys 'tat && exit' 'C-m'
# navigating between session
bind-key j split-window -v "tmux switch-client -t `tmux list-sessions | sed -E 's/:.*$//g' | grep -v \"^$(tmux display-message -p '#S')\" | fzf-tmux -p -w 70% -h 70%`"
# kill session and switch to next session
bind-key K run-shell 'tmux switch-client -n \; kill-session -t "$(tmux display-message -p "#S")" || tmux kill-session'
# Status Bar ---------------------
#
# set -g status on
# soften status bar colors
# set -g status-bg '#586e75'
# set -g status-fg '#eee8d5'
# Configuration status bar
# remove administrative debris (session name, hostname, time) in status bar
# set -g status-left ''
# set -g status-right ''
#
# set -g status-justify left
# set -g status-bg 'color237'
# set-option -g status-left-length 50
# set -g status-left "Session: #S"
#
# set-option -g status-right "%a, %d/%m/%y %H:%M"
# background for window status
# setw -g window-status-current-fg colour81
# setw -g window-status-current-bg colour238
# setw -g window-status-current-format ' #I#[fg=colour250]:#[fg=colour255]#W#[fg=colour50]#F '
# color for ACTIVE panel
# set -g pane-active-border-style '#{?pane_in_mode,fg=yellow,#{?synchronize-panes,fg=red,fg=red}}'
# Shift + arrows to resize pane
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-key c new-window -c '#{pane_current_path}'
bind-key k confirm kill-window
bind-key Left run 'tmux swap-window -d -t #{e|-|:#I,1}'
bind-key Right run 'tmux swap-window -d -t #{e|+|:#I,1}'
# Enable native Mac OS X copy/paste
set-option -g default-command "/bin/bash -c 'which reattach-to-user-namespace >/dev/null && exec reattach-to-user-namespace $SHELL -l || exec $SHELL -l'"
# --- VIM style tmux config ----
# smart pane switching with awareness of vim splits
# decide whether we're in a Vim process
# is_vim='echo "#{pane_current_command}" | grep -iqE "(^|\/)g?(view|n?vim?)(diff)?$"'
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 -n 'C-Space' if-shell "$is_vim" 'send-keys C-Space' 'select-pane -t:.+'
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
bind-key -T copy-mode-vi 'C-Space' select-pane -t:.+
# Allow mouse usage and copy pasting behavior (Compat with Tmux 2.4+)
set -g mouse on
bind-key -T copy-mode-vi WheelUpPane send-keys -X scroll-up
bind-key -T copy-mode-vi WheelDownPane send-keys -X scroll-down
unbind -T copy-mode-vi MouseDragEnd1Pane
bind-key -T edit-mode-vi Up send-keys -X history-up
bind-key -T edit-mode-vi Down send-keys -X history-down
unbind-key -T copy-mode-vi Space ; bind-key -T copy-mode-vi v send-keys -X begin-selection
unbind-key -T copy-mode-vi Enter ; bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "reattach-to-user-namespace pbcopy"
unbind-key -T copy-mode-vi C-v ; bind-key -T copy-mode-vi C-v send-keys -X rectangle-toggle
unbind-key -T copy-mode-vi [ ; bind-key -T copy-mode-vi [ send-keys -X begin-selection
unbind-key -T copy-mode-vi ] ; bind-key -T copy-mode-vi ] send-keys -X copy-selection
bind-key h split-window -v -c '#{pane_current_path}'
bind-key v split-window -h -c '#{pane_current_path}'
# Tmux plugins
# To install new plugins press: prefix + I
set -g @plugin 'tmux-plugins/tpm' # Tmux package manager
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'tmux-plugins/tmux-open' # Open highlighted selection directly from Tmux
set -g @plugin 'tmux-plugins/tmux-resurrect' # Restore previous sessions on reboot
set -g @plugin 'tmux-plugins/tmux-continuum' # Restore previous sessions on reboot
# set -g @plugin 'tmux-plugins/tmux-battery' #Show battery icon/status
set -g @plugin 'xamut/tmux-weather'
set -g @plugin 'sainnhe/tmux-fzf'
set -g @plugin 'wfxr/tmux-fzf-url' # list url in window
# Tmux will auto-start on system boot
set -g @continuum-boot 'on'
set -g @continuum-boot-options 'iterm'
set -g @continuum-restore 'on'
set -g @continuum-save-interval '5'
set -g @resurrect-strategy-vim 'session'
set -g @resurrect-strategy-nvim 'session' #for Neo Vim
set -g @fzf-url-bind 'u'
# ============== THEME =============
# COLORSCHEME: gruvbox dark (medium)
set-option -g status "on"
# default statusbar color
set-option -g status-style bg=colour237,fg=colour223 # bg=bg1, fg=fg1
# default window title colors
set-window-option -g window-status-style bg=colour214,fg=colour237 # bg=yellow, fg=bg1
# default window with an activity alert
set-window-option -g window-status-activity-style bg=colour237,fg=colour248 # bg=bg1, fg=fg3
# active window title colors
set-window-option -g window-status-current-style bg=red,fg=colour237 # fg=bg1
# pane border
set-option -g pane-active-border-style fg=red #colour250 #fg2
set-option -g pane-border-style fg=yellow #colour237 #bg1
# message infos
set-option -g message-style bg=colour239,fg=colour223 # bg=bg2, fg=fg1
# writing commands inactive
set-option -g message-command-style bg=colour239,fg=colour223 # bg=fg3, fg=bg1
# pane number display
set-option -g display-panes-active-colour colour214 #colour250 #fg2
set-option -g display-panes-colour colour253 #bg1
# clock
set-window-option -g clock-mode-colour colour109 #blue
# bell
set-window-option -g window-status-bell-style bg=colour167,fg=colour235 # bg=red, fg=bg
# Default location for weather
set-option -g @tmux-weather-location "HaNoi"
## Theme settings mixed with colors (unfortunately, but there is no cleaner way)
set-option -g status-bg 'color237'
set-option -g status-justify "left"
set-option -g status-left-style none
set-option -g status-left-length "80"
set-option -g status-right-style none
set-option -g status-right-length "80"
set-window-option -g window-status-separator ""
set-option -g status-left "#[bg=colour237,fg=colour248,bold] #S "
set-option -g status-right "#{weather} #[bg=colour237,fg=colour239 nobold, nounderscore, noitalics]#[bg=colour239,fg=colour246] %A, %d-%b-%Y "
set-window-option -g window-status-current-format "#[bg=colour214,fg=colour237,nobold,noitalics,nounderscore]#[bg=colour214,fg=colour239] #I #[bg=colour214,fg=colour239,bold] #W#{?window_zoomed_flag,*Z,} #[bg=colour237,fg=colour214,nobold,noitalics,nounderscore]"
set-window-option -g window-status-format "#[bg=colour239,fg=colour237,noitalics]#[bg=colour239,fg=colour223] #I #[bg=colour239,fg=colour223] #W #[bg=colour237,fg=colour239,noitalics]"
# Initializes Tmux plugin manager.
# Keep this line at the very bottom of tmux.conf.
run-shell '~/.tmux/plugins/tpm/tpm'