-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.tmux.conf
161 lines (125 loc) · 6.04 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
# Local overrides
source-file -q "$HOME/.config-local/tmux/tmux-before.conf"
set -g default-terminal "screen-256color"
set-option -ga terminal-overrides ",xterm-256color:Tc"
if-shell "type 'reattach-to-user-namespace' >/dev/null" "set -g default-command 'reattach-to-user-namespace -l $SHELL'"
TMUX_COLOR_WIN_ACTIVE_BG='#173347'
TMUX_COLOR_WIN_ACTIVE_FG='#feffff'
TMUX_COLOR_WIN_INACTIVE_BG='#102535'
TMUX_COLOR_WIN_INACTIVE_FG='#b5b5b5'
TMUX_COLOR_STATUS_BG='#017f00'
TMUX_COLOR_STATUS_FG='#efefef'
# soften status bar color
set -g status-bg "$TMUX_COLOR_STATUS_BG"
set -g status-fg "$TMUX_COLOR_STATUS_FG"
# set inactive/active window styles
set -g window-style "fg=$TMUX_COLOR_WIN_INACTIVE_FG bg=$TMUX_COLOR_WIN_INACTIVE_BG"
set -g window-active-style "fg=$TMUX_COLOR_WIN_ACTIVE_FG bg=$TMUX_COLOR_WIN_ACTIVE_BG"
set -g pane-border-style fg="$TMUX_COLOR_STATUS_BG",bg="$TMUX_COLOR_WIN_INACTIVE_BG"
set -g pane-active-border-style fg="$TMUX_COLOR_WIN_ACTIVE_FG",bg="$TMUX_COLOR_WIN_ACTIVE_BG"
set -g status-left "#{?client_prefix, ✦, ▹} [#{=/18/..:session_name}] "
set -g status-left-length 25
set -g status-right "#{pane_current_command} (#h)"
set -g status-right-length 40
set -g window-status-current-style 'underscore'
# change action key from ctrl-b to `
unbind C-b
set-option -g prefix `
bind ` send-prefix
# start window numbering from 1 instead of 0
set -g base-index 1
set -g pane-base-index 1
set -g history-limit 50000
set -g display-time 3000
# open new windows in current path, not directory where session was started
bind c new-window -c "#{pane_current_path}"
# split panes using | and -
bind | split-window -h -c '#{pane_current_path}'
bind - split-window -v -c '#{pane_current_path}'
# switch panes using Alt-arrow and Alt-vim directions without prefix
bind -n M-Left select-pane -L
bind -n M-Down select-pane -D
bind -n M-Up select-pane -U
bind -n M-Right select-pane -R
bind -n M-h select-pane -L
bind -n M-j select-pane -D
bind -n M-k select-pane -U
bind -n M-l select-pane -R
# also switch panes using vim-style selection
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
# With vim-tmux-navigator, <ctrl-l> is mapped to change to panel on right
# rather than default redraw screen. Add mapping so redraw screen can be done
# with <tmux-prefix><ctrl-L>.
bind C-l send-keys 'C-l'
# clear scrollback buffer
# (adapted from http://notes.jerzygangi.com/the-only-way-that-actually-works-to-clear-the-screen-in-tmux/)
bind-key C-k send-keys -R \; send-keys C-l \; clear-history
# create new window and immediately prompt for name (wish it could be shift-c, but this will do)
bind-key C-c new-window \; command-prompt -I '' "rename-window '%%'"
# Resize the current pane
bind-key -n S-Up resize-pane -U 5
bind-key -n S-Down resize-pane -D 5
bind-key -n S-Left resize-pane -L 10
bind-key -n S-Right resize-pane -R 10
# Reorder windows
bind-key < swap-window -t -1\; select-window -t -1
bind-key > swap-window -t +1\; select-window -t +1
# enable mouse control (clickable windows, panes, resizeable panes)
set -g mouse on
setw -g mode-keys vi
# enable focus events (fix up certain vim behavior, see https://github.com/tmux-plugins/vim-tmux-focus-events )
set -g focus-events on
# vi-style copying
# use 'y' to copy to system clipboard (Mac only), Enter still uses tmux's register only
bind-key -T copy-mode-vi v send -X begin-selection
bind-key -T copy-mode-vi V send-keys -X rectangle-toggle
bind-key -T copy-mode-vi Y send-keys -X copy-end-of-line
bind-key -T copy-mode-vi y send -X copy-selection-and-cancel
if-shell "type 'reattach-to-user-namespace' >/dev/null" \
"bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel 'reattach-to-user-namespace pbcopy'"
# scroll wheel (https://github.com/tmux/tmux/issues/145)
bind -n WheelUpPane if-shell -F -t = "#{mouse_any_flag}" "send-keys -M" "if -Ft= '#{pane_in_mode}' 'send-keys -M' 'select-pane -t=; copy-mode -e; send-keys -M'"
bind -n WheelDownPane select-pane -t= \; send-keys -M
# automatically set window title
set-window-option -g automatic-rename on
set-option -g set-titles on
set-option -g set-titles-string "#{session_name} - #{host}"
set-option -g renumber-windows on
# Smart pane switching with awareness of vim splits
# See: https://github.com/christoomey/vim-tmux-navigator
is_vim='echo "#{pane_current_command}" | grep -iqE "(^|\/)g?(view|n?vim?x?)(diff)?$"'
bind -n 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"
# make vim ESC work immediately, not after a half-second delay
set -sg escape-time 0
# capture tmux pane scrollback to a file (https://unix.stackexchange.com/questions/26548/write-all-tmux-scrollback-to-a-file)
bind-key P command-prompt -p 'save history to filename:' -I '~/tmux.history' 'capture-pane -S - ; save-buffer %1 ; delete-buffer'
# tmux plugins
# Do `git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm` first
# Then `<tmux>-I` within tmux session to install
#
# List of plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-copycat'
set -g @plugin 'tmux-plugins/tmux-open'
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'kjhaber/tmux-editpanecontent'
# Smart pane switching with awareness of vim splits
# (BTW, in iTerm2, be sure to map Ctrl-H to send escape sequence [104;5u
# This is CSI code for otherwise terminal will send <BS> key, which won't trigger
# Ctrl-H mappings. See also https://gitlab.com/gnachman/iterm2/issues/3519 )
set -g @plugin 'christoomey/vim-tmux-navigator'
set -g @shell_mode 'vi'
set -g @sidebar-tree-command 'tree -C'
# Load environment-specific plugins, if any
source-file -q "$HOME/.config/tmux/tmux-plugins.conf"
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'
# Local overrides (ok, tpm init isn't quite very bottom anymore)
source-file -q "$HOME/.config-local/tmux/tmux-after.conf"