-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.tmux.conf
183 lines (142 loc) · 6.35 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
# Load plugins.
# List of plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'tmux-plugins/tmux-yank' # Cross-platform support for clipboard.
set -g @plugin 'odedlaz/tmux-onedark-theme' # OneDark Theme
set -g @plugin 'tmux-plugins/tmux-resurrect' # Save/Restore sessions
set -g @plugin 'tmux-plugins/tmux-continuum' # Auto Save/Restore
# Remap prefix to ctrl-a for screen consistency.
# set -g prefix C-a
# Restore using continuum.
set -g @continuum-restore 'on'
# Shell management.
# Set the default shell, and set the default command to use our shell (this
# means we source things properly, show the correct PS1 etc).
set -g default-shell ${SHELL}
set -g default-command ${SHELL}
# Mouse management.
# Enable mouse mode (tmux 2.1 and above)
#set -g mouse on
# Colour management (yikes).
# Use 256 colours.
set-option -ga terminal-overrides ",xterm-256color:Tc"
set-option -g default-terminal "screen-256color"
# Nested session configuration.
# Use ^b b to send the leader to a nested session. This means if you are
# using tmux and then ssh into a tmux session (i.e. a nested session) you
# can run commands in the nested session with ^B b <command>.
bind-key b send-prefix
# Keyboard Management.
# Don't wait for an escape sequence after hitting
# Esc. fixes insert mode exit lag in vim.
set -sg escape-time 0
# Clipboard / Copy / Paste
# Note: This is heavily OS dependent, which is why we have separate versions
# for OSX, Ubuntu etc. I'm trying out tmux-yank for this but it is still work in
# progress.
# Use vim keybindings in copy mode
setw -g mode-keys vi
# Setup 'v' begin/end selection as in Vim.
bind-key -T copy-mode-vi v send-keys -X begin-selection
# Pane and Window Management.
# Open new panes and splits in the same working directory.
bind c new-window -c "#{pane_current_path}"
# Set the name of the window initially, but then don't let tmux change it.
# The name can still be set at any time with Ctrl+B + ,
set-option -g allow-rename off
# Start windows and panes at 1.
set -g base-index 1
set -g pane-base-index 1
# When we add/remove windows, renumber them in sequential order.
set -g renumber-windows on
# Split panes using | and -
bind | split-window -h -c "#{pane_current_path}"
bind - split-window -v -c "#{pane_current_path}"
# Ctrl+B h/l to swap windows left/right, i.e. moving the tabs around.
bind-key h swap-window -t -1\; select-window -t -1
bind-key l swap-window -t +1\; select-window -t +1
# Smart pane switching with awareness of Vim splits, as well as Ctrl+HJKL in
# the fzf command.
# See: https://github.com/christoomey/vim-tmux-navigator
# See: https://www.bugsnag.com/blog/tmux-and-vim
is_vim="ps -o state= -o comm= -t '#{pane_tty}' | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"
is_fzf="ps -o state= -o comm= -t '#{pane_tty}' | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?fzf$'"
bind -n C-h run "($is_vim && tmux send-keys C-h) || \
tmux select-pane -L"
bind -n C-j run "($is_vim && tmux send-keys C-j) || \
($is_fzf && tmux send-keys C-j) || \
tmux select-pane -D"
bind -n C-k run "($is_vim && tmux send-keys C-k) || \
($is_fzf && tmux send-keys C-k) || \
tmux select-pane -U"
bind -n C-l run "($is_vim && tmux send-keys C-l) || \
tmux select-pane -R"
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-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\' 'select-pane -l'"
if-shell -b '[ "$(echo "$tmux_version >= 3.0" | bc)" = 1 ]' \
"bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\\\' 'select-pane -l'"
bind-key -T copy-mode-vi C-h select-pane -L
bind-key -T copy-mode-vi C-j select-pane -D
bind-key -T copy-mode-vi C-k select-pane -U
bind-key -T copy-mode-vi C-l select-pane -R
# bind-key -T copy-mode-vi C-\ select-pane -l
# Meta + h/l to cycle through tabs.
bind-key -n M-h previous-window
bind-key -n M-l next-window
# Ctr + Meta + h/j/k/l to resize panes.
bind-key -n C-M-h resize-pane -L 2
bind-key -n C-M-j resize-pane -D 2
bind-key -n C-M-k resize-pane -U 2
bind-key -n C-M-l resize-pane -R 2
# Enable focus events, which are needed to keep vim's focus events working when
# vim is running inside tmux.
set -g focus-events on
## Status bar design
# set -g status-utf8 on
set -g status-justify left
set -g status-bg default
set -g status-interval 2
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'
# Customise the visuals on top of One Dark for tmux. Might be good to put into
# its own file at some stage.
onedark_black="#282c34"
dark_black="#1c1c1c"
white="#ffffff"
set -g pane-border-bg "$onedark_black"
set -g pane-border-fg colour238
set -g pane-active-border-bg "$onedark_black"
set -g pane-active-border-fg colour14
# Info on left (I don't have a session display for now)
set -g status-left ''
# loud or quiet?
set-option -g visual-activity off
set-option -g visual-bell off
set-option -g visual-silence off
set-window-option -g monitor-activity off
set-option -g bell-action none
set -g status-position bottom
set -g status-bg colour234
set -g status-fg colour137
set -g status-attr dim
set -g status-left '#S'
set -g status-left-bg "$dark_black"
set -g status-right '#[fg=colour245] %Y-%m-%d #[fg=colour245] %H:%M:%S '
# setw -g status-right-fg colour138
# setw -g status-right-bg "$dark_black"
set -g status-right-length 50
set -g status-left-length 20
setw -g window-status-current-fg colour14
setw -g window-status-current-bg colour238
setw -g window-status-current-attr bold
setw -g window-status-current-format ' #I#[fg=colour250]:#[fg=colour255]#W#[fg=colour50]#F '
setw -g window-status-fg colour138
setw -g window-status-bg "$dark_black"
setw -g window-status-attr none
setw -g window-status-format ' #I#[fg=colour237]:#[fg=colour250]#W#[fg=colour244]#F '
setw -g window-status-bell-attr bold
setw -g window-status-bell-fg colour255
setw -g window-status-bell-bg colour1
run -b '~/.tmux/plugins/tpm/tpm'