-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtmux.conf
176 lines (131 loc) · 6.16 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
# improve colors
set-option -g default-terminal "tmux-256color"
set-option -a terminal-features 'tmux-256color:RGB'
set-option -ga terminal-overrides ",*256col*:Tc"
set -s escape-time 0
# re-mapping prefix key
unbind C-b
set -g prefix C-a
bind-key C-a send-prefix # double C-a to send C-a. Very helpful in vim
# bind-key X {command} = prefix + X
# Reload config
bind-key r source-file ~/.tmux.conf \; display-message "~/.tmux.conf reloaded"
# ====================
# OPTIONS configuration
# Enable native Mac OS X copy/paste
set-option -g default-command "/bin/zsh -c 'which reattach-to-user-namespace >/dev/null && exec reattach-to-user-namespace $SHELL -l || exec $SHELL -l'"
# 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
# select-layout
set -g main-pane-height 70%
set -g main-pane-width 70%
# ===================
# KEY MAPPING
# clear history
bind-key -n C-b send-keys -R \; clear-history \; send-keys C-l
# navigating between session
bind-key j run-shell 'fsession'
bind-key C-p run-shell 'fpass'
# 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'
bind-key h split-window -v -c '#{pane_current_path}'
bind-key v split-window -h -c '#{pane_current_path}'
bind-key Left run 'tmux swap-window -d -t #{e|-|:#I,1}'
bind-key Right run 'tmux swap-window -d -t #{e|+|:#I,1}'
# 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
# ============== 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
## 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]"
# =========================
# closed to VIM user
set-window-option -g mode-keys vi
is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
| grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"
# navigating between pane
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 -n 'C-Space' if-shell "$is_vim" 'send-keys C-Space' 'select-pane -t:.+'
# still support navigating in copy-mode
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-Space' select-pane -t:.+
# Select, copy, paste
bind-key -T copy-mode-vi v send -X begin-selection
bind-key -T copy-mode-vi y send -X copy-selection
bind-key -T copy-mode-vi C-v send-keys -X rectangle-toggle
bind-key -T copy-mode-vi Enter send -X copy-pipe-and-cancel "pbcopy"
# ===========
# Mouse configurationset -g mouse on
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
# ==================================
# Tmux plugins
# To install new plugins press: prefix + I (capital i)
set -g @plugin 'tmux-plugins/tpm' # Tmux package manager
set -g @plugin 'tmux-plugins/tmux-sensible'
# list and fuzzy search URL
# set -g @plugin 'wfxr/tmux-fzf-url'
set -g @plugin 'junegunn/tmux-fzf-url'
set -g @fzf-url-bind 'u'
# weather
set -g @plugin 'xamut/tmux-weather'
set-option -g @tmux-weather-location "HaNoi"
set -g @plugin 'tmux-plugins/tmux-resurrect' # Restore previous sessions on reboot
set -g @plugin 'tmux-plugins/tmux-continuum' # Restore previous sessions on reboot
# 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
# Initializes Tmux plugin manager.
# Keep this line at the very bottom of tmux.conf.
run-shell '~/.tmux/plugins/tpm/tpm'