-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.tmux.conf
220 lines (170 loc) · 7.09 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
212
213
214
215
216
217
218
219
220
# Settings
# --------------------------------------------------------------------------------------------------
# set-window-option -g aggressive-resize off
set-window-option -g aggressive-resize on
# 親端末のTERMがxtermの場合
set-option -g terminal-overrides 'xterm*:smcup@:rmcup@'
set-option -g default-terminal 'screen-256color'
set-option -g terminal-overrides 'xterm:colors=256'
set-option -g default-shell /usr/local/bin/zsh
set-option -sg escape-time 0
# Mouse
# --------------------------------------------------------------------------------------------------
# > There do not appear to be any default bindings for the mouse wheel in 2.1. You'll need to add them.
# One of the changes in 2.1 is to make mouse events bindable instead of having the behavior built in.
# cf. [tmux 2.1 has been released : tmux](https://www.reddit.com/r/tmux/comments/3paqoi/tmux_21_has_been_released/)
if-shell "~/dotfiles/bin/tmux-check-version 2.0" '\
set-option -g mouse on; \
'
unbind -T root WheelUpPane
unbind -T root WheelDownPane
bind -T root WheelUpPane if -Ft= '#{mouse_any_flag}' 'send-keys -M' 'if -Ft= "#{pane_in_mode}" "send-keys -M" "copy-mode -eu"'
bind-key -T copy-mode-vi WheelUpPane send -X halfpage-up
bind-key -T copy-mode-vi WheelDownPane send -X halfpage-down
# ウィンドウ分割後もカレントディレクトリに留まる
if-shell "~/dotfiles/bin/tmux-check-version 1.9" '\
bind n new-window -c "#{pane_current_path}"; \
bind h split-window -h -c "#{pane_current_path}"; \
bind v split-window -v -c "#{pane_current_path}"; \
'
# Status
# --------------------------------------------------------------------------------------------------
set-window-option -g allow-rename off
set-window-option -g monitor-activity on
set-option -g visual-activity on
set-window-option -g window-status-current-format "#[fg=colour255,bg=colour241,bold] #I: #W #[default]"
if-shell "~/dotfiles/bin/tmux-check-version 1.7" '\
set-option -g status-position top; \
'
# Start window numbers at 1
set-option -g base-index 1
set-window-option -g pane-base-index 1
# Renumber windows sequentially after closing any of them
if-shell "~/dotfiles/bin/tmux-check-version 1.7" '\
set-option -g renumber-windows on; \
'
# Status
set-option -g status-justify left
# Left panel
set-option -g status-left-length 50
set-option -g status-left \
"#{?client_prefix,#[reverse],}#[fg=green][#S:#I.#P]#[fg=yellow][#(whoami)@#h] "
# Right panel
set-option -g status-right-length 80
set-option -g status-right \
"#{?client_prefix,#[reverse],}"\
"#[fg=green]#(${HOME}/dotfiles/bin/git-echo-tmux-current-branch)"
# Color
# --------------------------------------------------------------------------------------------------
# window
set-option -g window-style 'fg=colour247,bg=colour236'
set-option -g window-active-style 'fg=colour250,bg=black'
# default statusbar colors
set-option -g status-style fg=yellow,bg=black
# default window title colors
set-window-option -g window-status-style fg=brightblue,bg=default
# set-window-option -g window-status-attr dim
# active window title colors
set-window-option -g window-status-current-style fg=brightred,bg=default
# set-window-option -g window-status-current-attr bright
# pane border
set-option -g pane-border-style fg=black
set-option -g pane-active-border-style fg=brightgreen
# message text
set-option -g message-style fg=brightred,bg=black
# pane number display
set-option -g display-panes-active-colour blue #blue
set-option -g display-panes-colour brightred #orange
# clock
set-window-option -g clock-mode-colour green #green
# Keybindings
# --------------------------------------------------------------------------------------------------
# Change prefix
# unbind C-b
# set-option -g prefix2 C-Space
# set-option -g prefix2 C-s
# bind-key Space send-prefix
# Reload config
bind-key r source-file ~/.tmux.conf \; display ".tmux.conf Reloaded"
# Use vim-like keybindings
set-window-option -g mode-keys vi
# Copy mode
# --------------------------------------------------------------------------------------------------
unbind-key -T copy-mode-vi Space
bind-key -T copy-mode-vi v send -X begin-selection
# Esc キーでコピーの反転を解除(コピーモードは抜けない)
bind-key -T copy-mode-vi Escape send -X clear-selection
# For Linux
if-shell "which xsel" '\
unbind-key -T copy-mode-vi Enter; \
bind-key -T copy-mode-vi y send -X copy-pipe-and-cancel "xsel -ib"; \
bind-key -T copy-mode-vi Enter send -X copy-pipe-and-cancel "xsel -ib"; \
'
# bind-key c copy-mode
# bind-key p paste-buffer
# Move pane/window
bind-key Space last-window
bind-key C-Space last-window
bind-key -r C-p select-window -t :-
bind-key -r C-n select-window -t :+
bind-key -n M-Left select-window -t :-
bind-key -n M-Right select-window -t :+
# bind-key -r C-i previous-window
# bind-key -r C-o next-window
# Smart pane switching with awareness of vim splits
# cf. [christoomey/vim-tmux-navigator](https://github.com/christoomey/vim-tmux-navigator)
is_vim='echo "#{pane_current_command}" | grep -iqE "(^|\/)g?(view|n?vim?)(diff)?$"'
bind -r C-h if-shell "$is_vim" "send-keys C-h" "select-pane -L"
bind -n C-j if-shell "$is_vim" "send-keys C-j" "select-pane -D"
bind -n C-k if-shell "$is_vim" "send-keys C-k" "select-pane -U"
bind -n C-l if-shell "$is_vim" "send-keys C-l" "select-pane -R"
bind -n 'C-\' if-shell "$is_vim" "send-keys 'C-\\'" "select-pane -l"
# Resize pane
bind-key -r h resize-pane -L
bind-key -r j resize-pane -D
bind-key -r k resize-pane -U
bind-key -r l resize-pane -R
# Select window
bind-key b choose-window
# Create new window
bind-key n new-window
# Split window
bind-key s split-window -v -c '#{pane_current_path}'
bind-key v split-window -h -c '#{pane_current_path}'
bind-key C-s split-window -v -c '#{pane_current_path}'
bind-key C-v split-window -h -c '#{pane_current_path}'
# Other
bind-key q kill-pane
bind-key Q kill-window
bind-key C-q kill-pane
bind-key C-Q kill-window
bind-key A set-window-option synchronize-panes on
bind-key a set-window-option synchronize-panes off
bind-key C-A set-window-option synchronize-panes on
bind-key a set-window-option synchronize-panes off
bind-key i send-keys -R \; clear-history
bind-key C-i send-keys -R \; clear-history
bind-key o send-keys -R \; clear-history
bind-key C-o send-keys -R \; clear-history
# Plugins
# --------------------------------------------------------------------------------------------------
# Install tmux plugins using Tmux Plugin Manager
# tmux-plugins/tmux-yank
set-option -g @tpm_plugins ' \
tmux-plugins/tpm \
tmux-plugins/tmux-copycat \
tmux-plugins/tmux-open \
tmux-plugins/tmux-resurrect \
'
set-option -g @resurrect-strategy-vim 'session'
set-option -g @resurrect-strategy-nvim 'session'
# set-option -g @resurrect-save 'S'
# set-option -g @resurrect-restore 'R'
run-shell '~/.tmux/plugins/tpm/tpm'
# Editor
# --------------------------------------------------------------------------------------------------
# For shell vi mode compatibility
set-option -g @shell_mode 'vi'
# Clipboard
# --------------------------------------------------------------------------------------------------
set-option -g default-command "reattach-to-user-namespace -l zsh"