-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.tmux.conf
216 lines (188 loc) · 9.51 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
# document
# http://man.openbsd.org/OpenBSD-current/man1/tmux.1#set-environment
# environment
# 環境変数の指定
# set-environment (alias: setenv
# 環境変数にはglobal environmentとsession environmentがあり、サーバが開始されると環境変数をglobal envrionmentへコピーする
# sessionは固有のsession environmentを持ち、session envrironmentとglobal environmentが統合される。両方に同じ変数が存在した場合にsession environmentが利用される
#if-shell true {
#}
# 設定ファイル
SOURCE_FILE="${HOME}/.tmux.conf"
# color theme
BLACK="#232934"
BLACK_LIGHT="#686868"
YELLOW="#fad07b"
# options
# オプションの指定
# set-option (alias: set
# -p: paneオプションの指定
# -w: windowオプションの指定
# -s: serverオプションの指定
# 他指定はsessionオプションとなる
# オプションがuserオプションでなければ、tmuxはオプション名からオプションを推測するため-wまたは-sオプションを指定する必要はなく、paneオプションの-wと仮定する
# -gオプションが指定された場合、sessionかwindowオプションが設定される
## STYLES
# 色指定
# black, red, green, yellow, blue, magenta, cyan, ${FG_COLOUR}
# 利用できる場合 bright variants brightred, brightgreen, brightyellow
# to colour255 from the 256-colour set; default for the default colour; terminal for the terminal default colour; or a h0xadecimal rgb string such as ‘#ffffff’.
# 256-colourが設定されていた場合(tmux -2で256色を強制するなど) color0からcolour255
# defaultを指定した場合はtmuxのデフォルト色
# terminalを指定した場合はターミナルのデフォルト色
# 16桁のRGB指定
# フォント指定 acs(the terminal alternate character set)に指定できる値
# bright (or bold), dim, underscore, blink, reverse, hidden, italics, overline, strikethrough, double-underscore, curly-underscore, dotted-underscore, dashed-underscore
# デフォルトのprefixのキーバインドを解除
unbind-key ^b
# prefixを指定'None'の場合は指定なし
set-option -g prefix ^j
# prefix2のみを指定した場合、unbind-keyでデフォルトの^bを解除できない
#set-option -g prefix2 ^j
# escape入力時に、関数かメタキーの一部か判定する待機する時間(ms)
set-option -g escape-time 0 # The default is 500 milliseconds.
# bind-key -r で設定したキーバインドはprefixを押さずに再度入力できる
set-option -g repeat-time 250 # default 500
# キーが押されるまでステータスラインのメッセージを表示する
set-option -g display-time 0
# 履歴の保存行数
set-option -g history-limit 99999
## session
# マウス操作とイベントを有効にする
set-option -g mouse on
# copy modeでのキー操作をvi風に変更
set-option -g mode-keys vi
## status line
# satus lineの下に空白ができる場合は、ターミナルに設定された文字サイズがwindowの高さの倍数でないため
# https://github.com/gpakosz/.tmux/issues/193
# status lineやpane titleに利用可能な書式
# http://man.openbsd.org/OpenBSD-current/man1/tmux.1#FORMATS
STATUS_FOREGROUND_CLOUR=terminal
STATUS_BG_CLOUR=terminal
WINDOW_STATUS_FOREGROUND_CLOUR=terminal
WINDOW_STATUS_BG_CLOUR=terminal
CURRENT_WINDOW_STATUS_FOREGROUND_CLOUR=${YELLOW}
CURRENT_WINDOW_STATUS_BACKGROUND_CLOUR=terminal
STATUS_RIGHT_FOREGROUND_CLOUR=terminal
STATUS_RIGHT_BG_CLOUR=terminal
STATUS_LEFT_FOREGROUND_CLOUR=terminal
STATUS_LEFT_BG_CLOUR=terminal
WINDOW_STATUS_FORMAT='#{window_index}:#{window_name}'
set-option -g window-status-separator " " # default single space
# statusの有効化とサイズ指定(on|off|2|3|4|5)
set-option -g status on
# status lineを上に表示
set-option -g status-position bottom # (top|bottom)
# status lineの更新間隔を指定(sec)。0を指定した場合は再描画の間隔を無効にする
set-option -g status-interval 1 # default 15
# status line全体のstyle設定
set-option -g status-style fg=${STATUS_FOREGROUND_CLOUR},bg=${STATUS_BG_CLOUR}
# 単一のwindowのstyle指定
set-option -g window-status-style fg=${WINDOW_STATUS_FOREGROUND_CLOUR},bg=${WINDOW_STATUS_BG_CLOUR}
# window一覧のformatを指定
set-option -g window-status-format ${WINDOW_STATUS_FORMAT}
# 選択中のwindowのstyle指定
set-option -g window-status-current-style fg=${CURRENT_WINDOW_STATUS_FOREGROUND_CLOUR},bg=${CURRENT_WINDOW_STATUS_BACKGROUND_CLOUR}
# 選択中のwindowのformat指定
set-option -g window-status-current-format ${WINDOW_STATUS_FORMAT}
# 左端にsession情報を表示
# spacingの設定がないので行末に空白を指定
set-option -g status-left "[#{session_name}] "
# 左端のstyle指定
set-option -g status-left-style fg=${STATUS_LEFT_FOREGROUND_CLOUR},bg=${STATUS_LEFT_BG_CLOUR}
# 左端最大長を指定
set-option -g status-left-length 20 # default 10
# 右端に現在時刻を表示
set-option -g status-right " %Y-%m-%d %H:%M:%S "
# 右端のstyle指定
set-option -g status-right-style fg=${STATUS_RIGHT_FOREGROUND_CLOUR},bg=${STATUS_RIGHT_BG_CLOUR}
# 右端最大長を指定
set-option -g status-right-length 40 # default 40
## window
WINDOW_FOREGROUND_CLOUR=terminal
WINDOW_BACKGROUND_CLOUR=terminal
CURRENT_WINDOW_FOREGROUND_CLOUR=terminal
CURRENT_WINDOW_BACKGROUND_CLOUR=terminal
## 選択中windowのstyleを変更する
set-option -g window-style fg=${WINDOW_FOREGROUND_CLOUR},bg=${WINDOW_BACKGROUND_CLOUR}
set-option -g window-active-style fg=${CURRENT_WINDOW_FOREGROUND_CLOUR},bg=${CURRENT_WINDOW_BACKGROUND_CLOUR}
# windowのindexを1から始める
set-option -g base-index 1
# sessionを終了した時、windowのindexを連番で振り直す
set-option -g renumber-windows on # (on|off)
## pane
PANE_BORDER_FG_COLOUR=terminal
PANE_BORDER_BG_COLOUR=terminal
PANE_ACTIVE_BORDER_FG_COLOUR=${YELLOW}
PANE_ACTIVE_BORDER_BG_COLOUR=terminal
# paneのindexを1から始める
set-option -g pane-base-index 1
# paneのstatusを表示
set-option -g pane-border-status top # (off|top|bottom)
# ボーダーに表示するテキストを指定
set-option -g pane-border-format " #P #{pane_current_command} "
# paneのボーダーstyleを指定
set-option -g pane-border-style fg=${PANE_BORDER_FG_COLOUR},bg=${PANE_BORDER_BG_COLOUR}
# 選択中paneのボーダーstyleを指定
set-option -g pane-active-border-style fg=${PANE_ACTIVE_BORDER_FG_COLOUR},bg=${PANE_ACTIVE_BORDER_BG_COLOUR}
# statusの区切り文字を指定
## message
MESSAGE_COMMAND_FG_COLOUR=terminal
MESSAGE_COMMAND_BG_COLOUR=terminal
MESSAGE_FG_COLOUR=terminal
MESSAGE_BG_COLOUR=terminal
set-option -g message-command-style fg=${MESSAGE_COMMAND_FG_COLOUR},bg=${MESSAGE_COMMAND_BG_COLOUR}
# メッセージ表示のスタイル指定
set-option -g message-style fg=${MESSAGE_FG_COLOUR},bg=${MESSAGE_BG_COLOUR}
## mode
MODE_FG_COLOUR=terminal
MODE_BG_COLOUR=${BLACK_LIGHT}
# window選択画面のスタイルを指定
set-option -g mode-style fg=${MODE_FG_COLOUR},bg=${MODE_BG_COLOUR}
# bind-key [-nr] [-N note] [-T key-table] key command [arguments] (alias: bind
# -nオプション: -T rootのエイリアスでprefixの入力なしにkey commandを呼び出す
# -rオプション: リピートするキーに指定。間隔はrepeat-timeで指定
# send-keys [-FHlMRX] [-N repeat-count] [-t target-pane] key ... (alias: send
# -Mオプション: mouseイベントに受け渡す(mouseサポートを有効にしている場合)
# -Xオプション: copy modeにコマンドを送信する
# unbind-key [-anq] [-T key-table] key (alias: unbind
# option v でcopy-modeを開始
bind-key -n M-v copy-mode
bind-key -T copy-mode-vi v send-keys -X begin-selection
# Enter, y, マウスドラッグでtmuxのbufferとclipboardにコピー
# cope-pipe-and-cancelの場合カーソルが入力まで戻されるため利用しない
bind-key -T copy-mode-vi y send-keys -X copy-pipe "pbcopy"
bind-key -T copy-mode-vi Enter send-keys -X copy-pipe "pbcopy"
bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe "pbcopy"
# copy-modeをescapeで終了
bind-key -T copy-mode Escape send-keys -X cancel
# copy modeでない場合もマウスで選択した範囲をクリップボードにコピーする
bind-key MouseDragEnd1Pane send-keys -X cope-pipe-and-cancel "pbcopy"
# option [1-9]で数字に対応したwindowを選択
bind-key -n M-1 select-window -t 1
bind-key -n M-2 select-window -t 2
bind-key -n M-3 select-window -t 3
bind-key -n M-4 select-window -t 4
bind-key -n M-5 select-window -t 5
bind-key -n M-6 select-window -t 6
bind-key -n M-7 select-window -t 7
bind-key -n M-8 select-window -t 8
bind-key -n M-9 select-window -t 9
## paneの選択切り替えをprefix [hljk]で行う
bind-key -N 'Select the pane to the left of the active pane' -r h select-pane -L
bind-key -N 'Select the pane below the active pane' -r j select-pane -R
bind-key -N 'Select the pane above the active pane' -r k select-pane -D
bind-key -N 'Select the pane to the right of the active pane' -r l select-pane -U
# prefixなしでpaneを切り替え
bind-key -N 'Select next pane' -n ^o select-pane -t :.+
# paneのリサイズをprefix Ctrl+[hljk]で行う
# 一度のリサイズするpaneの大きさ
RESIZE_PANE_SIZE=10
bind-key -r ^h resize-pane -L ${RESIZE_PANE_SIZE}
bind-key -r ^j resize-pane -D ${RESIZE_PANE_SIZE}
bind-key -r ^k resize-pane -U ${RESIZE_PANE_SIZE}
bind-key -r ^l resize-pane -R ${RESIZE_PANE_SIZE}
# キーバインドを表示する
bind-key ? list-keys
# Shift+rで設定を読み込む
bind-key r source-file ${SOURCE_FILE} \; display-message "reload source-file #{SOURCE_FILE}"