/
.tmux.conf
104 lines (78 loc) · 4.05 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
#echo $TERM がxtermになるようにする。
#vimはこの設定を検知してtmuxの中でもtermguicolorsが使えるようになる。
set -g default-terminal xterm-256color
setw -g xterm-keys on
set -g history-limit 50000
#prefixキー+rで設定ファイルリロード
bind r source-file ~/.tmux.conf \; display "Reloaded"
set-window-option -g mode-keys vi
#うるさいベルをなくす
set-option -g bell-action none
# chshで変えられない場合、tmuxで使うシェルはここで変えられる
#set-option -g default-shell /bin/zsh
#prefixキーをctrl-bからctrl-space(押しやすいので)
#tmuxのキーバインドはすべてprefixキー+ほげの形にすることでvimとの衝突を防ぐ
#注意!Macだとctrl-spaceはスポットライトに割り当てられている
#unbind-key C-b
set -g prefix C-Space
bind-key C-Space send-prefix
bind y choose-buffer
tmux_version='$(tmux -V | sed -En "s/^tmux ([0-9]+(.[0-9]+)?).*/\1/p")'
if-shell -b '[ "$(echo "$tmux_version < 3.0" | bc)" = 1 ]' \
"bind -t vi-copy C-v rectangle-toggle"
if-shell -b '[ "$(echo "$tmux_version >= 3.0" | bc)" = 1 ]' \
"bind -T copy-mode-vi C-v send -X rectangle-toggle"
set -sg escape-time 20
#prefixキー+hjklで画面選択
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
bind Tab run-shell ~/dotfiles/tmux/tmux-comp.py
#マウス
#vscode integrated terminalで困る
set -g mouse off
set -g focus-events on
setw -g aggressive-resize on
# <prefix>+qで複数分割したペインのどれにジャンプするか数字で選択する
set-option -g display-panes-time 2147483647
# <prefix>+tで分割したpaneにコマンド同時送信を切り替える
bind-key t setw synchronize-panes \; display "synchronize-panes #{?pane_synchronized,on,off}"
# <prefix>+aでmouseをtmuxが解釈するかトグルする https://qiita.com/kawaz/items/7b15e18ca8e072c1dc57
bind-key a if-shell "tmux show-options -g mouse | grep off" "set-option -g mouse on \; display 'mouse on'" "set-option -g mouse off \; display 'mouse off'"
# https://github.com/microsoft/vscode-remote-release/issues/2763#issuecomment-682276412
# update VSCODE variables from integrated terminal so that `code` command opens in current window
set-option -ga update-environment ' VSCODE_GIT_ASKPASS_NODE VSCODE_GIT_ASKPASS_MAIN VSCODE_IPC_HOOK_CLI PATH GIT_ASKPASS'
# Tc enables true color
set -ag terminal-overrides ",*256col*:colors=256:Tc"
# Ms modifies OSC 52 clipboard handling to work with mosh, see
# https://gist.github.com/yudai/95b20e3da66df1b066531997f982b57b
set -ag terminal-overrides "vte*:XT:Ms=\\E]52;c;%p2%s\\7,xterm*:XT:Ms=\\E]52;c;%p2%s\\7"
# enable OSC 52 clipboard
# https://medium.freecodecamp.org/tmux-in-practice-integration-with-system-clipboard-bcd72c62ff7b
set -g set-clipboard on
#set -g window-style 'fg=colour247,bg=colour234'
#set -g window-active-style 'fg=colour255,bg=black'
# ウィンドウ/ペインの開始番号を1からにする(デフォルトは0から)
set -g base-index 1
setw -g pane-base-index 1
set -g message-command-style bg=black,fg=cyan
set -g message-style bg=black,fg=cyan
run-shell "/usr/bin/python3 $HOME/powerline/scripts/powerline-config tmux setup"
# 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 'M-h' if-shell "$is_vim" 'send-keys M-h' 'select-pane -L'
bind-key -n 'M-j' if-shell "$is_vim" 'send-keys M-j' 'select-pane -D'
bind-key -n 'M-k' if-shell "$is_vim" 'send-keys M-k' 'select-pane -U'
bind-key -n 'M-l' if-shell "$is_vim" 'send-keys M-l' 'select-pane -R'
bind-key -n 'M-\' select-pane -l
bind-key -T copy-mode-vi 'M-h' select-pane -L
bind-key -T copy-mode-vi 'M-j' select-pane -D
bind-key -T copy-mode-vi 'M-k' select-pane -U
bind-key -T copy-mode-vi 'M-l' select-pane -R
bind-key -T copy-mode-vi 'M-\' select-pane -l
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'ChanderG/tmux-notify'
run -b '~/.tmux/plugins/tpm/tpm'