-
Notifications
You must be signed in to change notification settings - Fork 0
/
.tmux.conf
192 lines (148 loc) · 5.52 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
set-option -g default-shell /bin/zsh
# initial setup
set -g status-keys vi
# Pass xterm-keys to the terminal
set-window-option -g xterm-keys on
# remap prefix from 'C-b' to 'C-a'
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix
# split horizontal panes using pipe or backslash with same path as current pane
bind | split-window -h -c '#{pane_current_path}'
bind '\' split-window -h -c '#{pane_current_path}'
# split vertical panes using underscore or dash with same path as current pane
bind _ split-window -v -c '#{pane_current_path}'
bind - split-window -v -c '#{pane_current_path}'
unbind '"'
# Resize panes with HJKL
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
# Swap window tabs
bind-key S-Left swap-window -t -1
bind-key S-Right swap-window -t +1
# Start windows and panes at index 1, not 0
set -g base-index 1
setw -g pane-base-index 1
# Mouse mode for those emergencies...
set -g mouse on
# tmux 2.9 introduced breaking changes to style configuration
# conditionally applies using newer syntax but also backwards compatible
# tmux >= v/2.9
if-shell "tmux -V | awk '{exit !($2 >= \"2.9\")}'" \
"\
set -g pane-border-style fg=colour235; \
set -g pane-active-border-style fg=cyan; \
set -g message-style bg=black,fg=yellow; \
set -g status-style bright,bg=colour235,fg=yellow; \
setw -g window-status-current-style bg=yellow,fg=black; \
"
# tmux >= v/2.8
# Spread panes out evenly
if-shell "tmux -V | awk '{exit !($2 >= \"2.8\")}'" \
"\
bind = select-layout -E; \
unbind-key E; \
"
# tmux < v/2.9
if-shell "tmux -V | awk '{exit !($2 < \"2.9\")}'" \
"\
set-option -g pane-border-fg colour235; \
set-option -g pane-active-border-fg cyan; \
set-option -g message-bg black; \
set-option -g message-fg yellow; \
set-option -g status-bg colour235; \
set-option -g status-fg yellow; \
set-option -g status-attr bright; \
set-window-option -g window-status-current-bg yellow; \
set-window-option -g window-status-current-fg black; \
"
# switch panes without using prefix
bind -n M-h select-pane -L
bind -n M-l select-pane -R
bind -n M-k select-pane -U
bind -n M-j select-pane -D
# Fast toggle between last window (normally prefix-l)
bind ^space last-window
# Auto renumber windows after closing one
set-option -g renumber-windows on
# set scrollback history to 10000 (10k)
set -g history-limit 10000
# make tmux display things in 256 colors
set -g default-terminal "screen-256color"
# dynamically update window titles
set -g set-titles on
# Report focus events
set -g focus-events on
# but don't change if window title named manually
set -w -g automatic-rename off
# re-source this tmux conf file
bind r source-file ~/.tmux.conf \; display "Reloaded!"
# shorten command delay
set -sg escape-time 1
# ----------------------
# Status Bar
# -----------------------
set-option -g status on # turn the status bar on
set -g status-interval 1 # set update frequencey (default 15 seconds)
set -g status-justify centre # center window list for clarity
# move status bar to the top
set-option -g status-position top
# clock
set-window-option -g clock-mode-colour colour76 #green
# show session name, window & pane number, date and time on right side of
# status bar
set -g status-left-length 40
set -g status-right-length 50
set -g status-right "#[fg=cyan]$USER@#h #[fg=yellow] %m-%d-%y #[fg=green] #(date | awk '{print $4}') "
# use vim keybindings
setw -g mode-keys vi
# Paste the contents of the last yank
bind-key 'p' paste-buffer
# tmux >= v/2.4
if-shell "tmux -V | awk '{exit !($2 >= \"2.4\")}'" \
"\
bind-key -T copy-mode-vi 'V' send-keys -X select-line; \
bind-key -T copy-mode-vi 'v' send-keys -X begin-selection; \
bind-key -T copy-mode-vi 'y' send-keys -X copy-pipe-and-cancel 'xclip -in -selection clipboard'; \
bind-key -T copy-mode-vi 'r' send-keys -X rectangle-toggle; \
"
# tmux < v/2.4
if-shell "tmux -V | awk '{exit !($2 < \"2.4\")}'" \
"\
bind-key -t vi-copy 'v' begin-selection; \
bind-key -t vi-copy 'y' copy-selection; \
bind-key -t vi-copy 'V' rectangle-toggle; \
set -g status-utf8 on; \
set -g utf8; \
set-window-option -g utf8 on; \
"
# Fix for weird MacOS issues with accessing system clipboard
# Fix requires install of 'reattach-to-user-namespace' which can be obtained through Homebrew
if-shell "type 'reattach-to-user-namespace' >/dev/null" "set -g default-command 'reattach-to-user-namespace -l $SHELL'"
set -g @yank_selection 'primary'
# Smart pane switching with awareness of Vim splits.
# See: https://github.com/christoomey/vim-tmux-navigator
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"
# Restore clear screen
bind C-l send-keys 'C-l'
# Tmux Session Restoration
# set -g @continuum-restore 'on'
# Plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'tmux-plugins/tmux-yank'
set -g @plugin 'tmux-plugins/tmux-resurrect'
# set -g @plugin 'tmux-plugins/tmux-continuum'
#Install -- prefix + I
#Update -- prefix + u
#Uninstall -- prefeix + alt + u
run-shell '~/.tmux/plugins/tmux-yank/yank.tmux'
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'