/
.tmux.conf
120 lines (99 loc) 路 3.5 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
# Remap prefix to Control + s
set -g prefix C-s
unbind-key C-b
bind-key C-s send-prefix
# Force a reload of the config file
unbind-key r
bind-key r source-file ~/.tmux.conf\; display-message "~/.tmux.conf reloaded"
# Quick pane cycling
# Double Ctrl+S cycles panes in a window
unbind-key ^S
bind-key ^S select-pane -t :.+
# 256 Color
set -g default-terminal "screen-256color"
# Use vim keybindings in copy mode
setw -g mode-keys vi
# Setup 'v' to begin selection as in Vim
unbind-key -T copy-mode-vi v
unbind-key -T copy-mode-vi y
unbind-key -T copy-mode-vi C-v
bind-key -T copy-mode-vi v send-keys -X begin-selection
bind-key -T copy-mode-vi C-v send-keys -X rectangle-toggle
# Update default binding of `Enter` to also use copy-pipe
unbind-key -T copy-mode-vi Enter
# Open new window with current directory
unbind-key '"'
unbind-key %
unbind-key c
bind-key '"' split-window -c "#{pane_current_path}"
bind-key % split-window -h -c "#{pane_current_path}"
bind-key c new-window -c "#{pane_current_path}"
# Navigate tmux panes & vim windows by C-s h/j/k/l
# 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)?$'"
unbind-key h
unbind-key j
unbind-key k
unbind-key l
bind-key h if-shell "$is_vim" "send-keys C-w h" "select-pane -L"
bind-key j if-shell "$is_vim" "send-keys C-w j" "select-pane -D"
bind-key k if-shell "$is_vim" "send-keys C-w k" "select-pane -U"
bind-key l if-shell "$is_vim" "send-keys C-w l" "select-pane -R"
# Resize split panes with < >
unbind-key <
unbind-key >
bind-key < resize-pane -L 10
bind-key > resize-pane -R 10
# Resize split panes with arrow keys
unbind-key Left
unbind-key Down
unbind-key Up
unbind-key Right
bind-key Left if-shell "$is_vim" "send-keys C-w h" "select-pane -L"
bind-key Down if-shell "$is_vim" "send-keys C-w j" "select-pane -D"
bind-key Left resize-pane -L 10
bind-key Right resize-pane -R 10
bind-key Up resize-pane -U 10
bind-key Down resize-pane -D 10
# Navigate tmux windows by C-s [/]
unbind-key n
unbind-key [
unbind-key ]
bind-key [ previous-window
bind-key ] next-window
# Enter copy mode by C-s p
# Enter copy mode from one page up by C-s C-u
unbind-key p
unbind-key C-u
bind-key p copy-mode
bind-key C-u copy-mode -eu
# Remove delay for ESC key
# http://unix.stackexchange.com/questions/23138/esc-key-causes-a-small-delay-in-terminal-due-to-its-alt-behavior
set -s escape-time 0
# Prevent tmux from exiting with Ctrl+D
# https://superuser.com/questions/479600/how-can-i-prevent-tmux-exiting-with-ctrl-d/1048864
set-environment -g 'IGNOREEOF' 10
# tmux focus mode
# https://superuser.com/questions/1261810/creating-a-focus-mode-for-tmux-one-centered-pane-flanked-by-two-blank-panes
bind-key C-g run-shell -b 'tmux-margins create'
bind-key C-d run-shell -b 'tmux-margins destroy'
bind-key C-a run-shell -b 'tmux-margins resurrect'
unbind-key -
unbind-key =
bind-key - run-shell -b 'tmux-margins -'
bind-key = run-shell -b 'tmux-margins +'
# Plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @resurrect-save 'S'
set -g @resurrect-restore 'R'
set -g @plugin 'tmux-plugins/tmux-continuum'
set -g @continuum-restore 'on'
run '~/.tmux/plugins/tpm/tpm'
# Load platform-specific configs
if-shell 'uname | grep -q Darwin' \
'source-file ~/dotfiles/.tmux.mac.conf' \
'source-file ~/dotfiles/.tmux.linux.conf'
# Load color theme. The file is generated by the `colorscheme` command.
source-file ~/dotfiles/.tmux.color.conf