264 lines
7.9 kB
1
# ╭──────┬───────╮
2
# │ tmux │ setup │
3
# ╰──────┴───────╯
4
5
rwx_tmux_setup() {
6
local file
7
file="${HOME}/.tmux.conf"
8
rwx_file_write "${file}" "\
9
# ╭────────╮
10
# │ option │
11
# ╰────────╯
12
13
# empty name for windows
14
set-option -g automatic-rename-format '#{pane_current_command}'
15
set-option -g automatic-rename on
16
17
# first index number
18
set-option -g base-index 1
19
20
# display duration
21
set-option -g display-time 1536
22
23
# extend history limit
24
set-option -g history-limit 1048576
25
26
# style for messages
27
set-option -g message-style bg=red,fg=white
28
29
# activity monitoring
30
set-window-option -g monitor-activity on
31
32
# silence monitoring
33
set-window-option -g monitor-silence 0
34
35
# enable mouse actions
36
set-option -g mouse on
37
38
# prefix with ^B or F12
39
set-option -g prefix C-b
40
set-option -g prefix2 F12
41
42
# renumber windows after closing one
43
set-option -g renumber-windows on
44
45
# enable title
46
set-option -g set-titles on
47
48
# set title to working directory
49
set-option -g set-titles-string '\
50
#{session_name}\
51
- \
52
#{window_index}∕#{session_windows} #{window_name}\
53
- \
54
#{pane_index}∕#{window_panes} #{pane_current_command}\
55
'
56
57
# ╭────────┬──────╮
58
# │ option │ pane │
59
# ╰────────┴──────╯
60
61
# first index number
62
set-option -g pane-base-index 1
63
64
# ╭────────┬──────┬────────╮
65
# │ option │ pane │ border │
66
# ╰────────┴──────┴────────╯
67
68
# active style
69
set-option -g pane-active-border-style fg=green
70
71
# regular style
72
set-option -g pane-border-style fg=blue
73
74
# ╭────────┬────────╮
75
# │ option │ status │
76
# ╰────────┴────────╯
77
78
# status lines
79
set-option -g status 3
80
81
# background color
82
set-option -g status-bg '#0D0D0D'
83
84
# foreground color
85
set-option -g status-fg white
86
87
# line 1
88
set-option -g status-format[0] '\
89
#{W:\
90
#[bg=##202020] #[bg=##303030]\
91
#{?window_zoomed_flag,#[fg=magenta][, }\
92
#[fg=yellow]#{window_index}\
93
#{?window_zoomed_flag,#[fg=magenta]], }\
94
\
95
#{?window_active,#[fg=green],\
96
#{?window_activity_flag,#[fg=red],#[fg=blue]}}\
97
#{window_name}\
98
#[bg=##303030] #[bg=##202020] \
99
#[bg=default] \
100
}\
101
#[align=right]\
102
#[bg=##202020] #[bg=##303030] \
103
#[fg=yellow]%H:%M:%S\
104
#[bg=##303030] #[bg=##202020]\
105
#{?client_prefix,#[fg=green]p, }\
106
'
107
108
# line 2
109
set-option -g status-format[1] '\
110
#{S:\
111
#[bg=##202020] #[bg=##303030] \
112
#{?session_many_attached,#[fg=red],\
113
#{?session_attached,#[fg=magenta],#[fg=blue]}}\
114
#{session_name}\
115
#[bg=##303030] #[bg=##202020] \
116
#[bg=default] \
117
}\
118
#[fg=yellow]→ #[fg=green]#{session_name} \
119
#[align=right]\
120
#[bg=##202020] #[bg=##303030] \
121
#[fg=yellow]%Y-%m-%d\
122
#[bg=##303030] #[bg=##202020] \
123
'
124
125
# line 3
126
set-option -g status-format[2] '\
127
#[fg=cyan]#{pane_current_path}\
128
#[align=right]\
129
#[bg=##202020] #[bg=##303030] \
130
#[fg=yellow]#{host}\
131
#[bg=##303030] #[bg=##202020] \
132
'
133
134
# line 4
135
set-option -g status-format[3] '\
136
#{P:\
137
#[bg=##202020] #[bg=##303030] \
138
#[fg=yellow]#{pane_index}\
139
\
140
#{?pane_active,#[fg=green],#[fg=blue]}\
141
#{pane_current_command}\
142
#[bg=##303030] #[bg=##202020] \
143
#[bg=default] \
144
}\
145
#[align=right]\
146
#[bg=##202020] #[bg=##303030] \
147
#{?uid,#[fg=green],#[fg=red]}\
148
#{user}\
149
#[bg=##303030] #[bg=##202020] \
150
'
151
152
# line 5
153
set-option -g status-format[4] '\
154
#{P:\
155
#[bg=##202020] #[bg=##303030] \
156
#[fg=yellow]#{pane_index}\
157
\
158
#{?pane_active,#[fg=green],#[fg=blue]}\
159
#{pane_width}×#{pane_height}\
160
#[bg=##303030] #[bg=##202020] \
161
#[bg=default] \
162
}\
163
#[align=right]\
164
#[bg=##202020] #[bg=##303030] \
165
#[fg=green]#{window_width}×#{window_height}\
166
#[bg=##303030] #[bg=##202020] \
167
'
168
169
# refresh period
170
set-option -g status-interval 1
171
172
# bar location
173
set-option -g status-position bottom
174
175
# ╭─────╮
176
# │ key │
177
# ╰─────╯
178
179
# detach client
180
bind-key -n F6 detach-client
181
182
# new window
183
bind-key -n F2 new-window
184
185
# select pane
186
bind-key -n C-S-Down select-pane -D
187
bind-key -n C-S-Left select-pane -L
188
bind-key -n C-S-Right select-pane -R
189
bind-key -n C-S-Up select-pane -U
190
191
# status lines
192
bind-key -n C-F10 set-option -g status off
193
bind-key -n C-F1 set-option -g status on
194
bind-key -n C-F2 set-option -g status 2
195
bind-key -n C-F3 set-option -g status 3
196
bind-key -n C-F4 set-option -g status 4
197
bind-key -n C-F5 set-option -g status 5
198
199
# switch session
200
bind-key -n M-Down switch-client -n
201
bind-key -n M-Up switch-client -p
202
203
# switch window
204
bind-key -n M-Left previous-window
205
bind-key -n M-Right next-window
206
207
# ╭─────┬────────╮
208
# │ key │ prefix │
209
# ╰─────┴────────╯
210
211
# rename
212
bind-key C-s command-prompt { rename-session '%%' }
213
bind-key C-w command-prompt { rename-window '%%' }
214
215
# split window
216
bind-key h split-window -h
217
bind-key v split-window -v
218
219
# toggle mouse
220
bind-key t set-option -g mouse \\; display-message 'mouse = #{mouse}'
221
222
# reload configuration
223
bind-key r source-file ${file} \\; display-message 'source-file ${file}'
224
225
# swap window
226
bind-key M-Left swap-window -t -1
227
bind-key M-Right swap-window -t +1
228
229
# ╭─────────────╮
230
# │ default │
231
# ╭───────────┬─────────┼─────┬───────┤
232
# │ -n │ F12 │ -n │ C-b │
233
# ╭───────────────────┼───────────┼─────────┼─────┼───────┤
234
# │ command-prompt │ │ │ │ : │
235
# │ copy-mode │ │ │ │ PPage │
236
# │ detach-client │ │ │ │ d │
237
# │ new-session │ │ │ │ │
238
# │ new-window │ F2 │ │ │ c │
239
# │ next-window │ M-Right │ │ │ n │
240
# │ previous-window │ M-Left │ │ │ p │
241
# │ rename-session │ │ C-s │ │ │
242
# │ rename-window │ │ C-w │ │ │
243
# │ resize-pane -Z │ │ │ │ z │
244
# │ select-pane -D │ C-S-Down │ │ │ │
245
# │ select-pane -L │ C-S-Left │ │ │ │
246
# │ select-pane -R │ C-S-Right │ │ │ │
247
# │ select-pane -U │ C-S-Up │ │ │ │
248
# │ set -g mouse │ │ t │ │ │
249
# │ set -g status off │ C-F10 │ │ │ │
250
# │ set -g status on │ C-F1 │ │ │ │
251
# │ set -g status 2 │ C-F2 │ │ │ │
252
# │ set -g status 3 │ C-F3 │ │ │ │
253
# │ set -g status 4 │ C-F4 │ │ │ │
254
# │ set -g status 5 │ C-F5 │ │ │ │
255
# │ source-file │ │ r │ │ │
256
# │ split-window -h │ │ h │ │ % │
257
# │ split-window -v │ │ v │ │ \" │
258
# │ swap-window -t -1 │ │ M-Left │ │ │
259
# │ swap-window -t +1 │ │ M-Right │ │ │
260
# │ switch-client -n │ M-Down │ │ │ │
261
# │ switch-client -p │ M-Up │ │ │ │
262
# ╰───────────────────┴───────────┴─────────┴─────┴───────╯
263
"
264
}
265