-
Notifications
You must be signed in to change notification settings - Fork 0
/
tmux.conf.symlink
186 lines (149 loc) · 6.11 KB
/
tmux.conf.symlink
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
# _ __
# | |_ _ __ ___ _ ___ __ ___ ___ _ __ / _|
# | __| '_ ` _ \| | | \ \/ / / __/ _ \| '_ \| |_
# | |_| | | | | | |_| |> < | (_| (_) | | | | _|
#(_)__|_| |_| |_|\__,_/_/\_(_)___\___/|_| |_|_|
# General:
# C-a Prefix
# C-a r Source .tmux.conf
# C-a ? Show key bindings
# C-a t Show time
#
# Sessions:
# C-a s List sessions
# C-a $ Rename session
#
# Windows (tabs):
# C-a c Create window
# C-a w List windows
# C-a f Find window
# C-a , Name window
# C-a & Kill window
#
# Panes (splits):
# C-a | Vertical split
# C-a - Horizontal split
# C-a o Jump between panes
# C-a q Show pane numbers (type number to jump)
# C-a x Kill pane
# C-a ! Break pane out into a window
# C-a j Create pane from an existing window
# C-a arrow Move between panes
set -g default-shell $SHELL
# tmux display things in 256 colors
set -g default-terminal "tmux-256color-italic"
# set -as terminal-overrides ',xterm*:Tc:sitm=\E[3m'
set -ga terminal-overrides ",*256col*:Tc"
set -g history-limit 20000
# automatically renumber tmux windows
set -g renumber-windows on
# unbind default prefix and set it to ` (backtick)
unbind C-b
set -g prefix `
# Allow to type ` for other purposes
bind-key ` send-prefix
# Activity Monitoring
setw -g monitor-activity off
set -g visual-activity off
# Rather than constraining window size to the maximum size of any client
# connected to the *session*, constrain window size to the maximum size of any
# client connected to *that window*. Much more reasonable.
setw -g aggressive-resize on
# make delay shorter
set -sg escape-time 0
# tile all windows
unbind =
bind = select-layout tiled
# cycle through panes
# unbind C-a
# unbind o # this is the default key for cycling panes
# bind ^A select-pane -t:.+
# make window/pane index start with 1
set -g base-index 1
setw -g pane-base-index 1
set-option -g set-titles on
set-option -g set-titles-string "#T - #W"
# set-window-option -g automatic-rename on
# Do not exit tmux when a session is killed
set-option -g detach-on-destroy off
######################
#### Key Bindings ####
######################
# reload config file or "tmux source ~/.tmux.conf" on the terminal
bind r source-file ~/.tmux.conf \; display "Config Reloaded!"
# split window and fix path for tmux 1.9
bind | split-window -h -c "#{pane_current_path}"
bind - split-window -v -c "#{pane_current_path}"
# synchronize all panes in a window
bind y setw synchronize-panes
# Kill all panes except the current one
bind k kill-pane -a
# 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 C-h if-shell "$is_vim" 'send-keys C-h' 'select-pane -L'
bind-key -n C-j if-shell "$is_vim" 'send-keys C-j' 'select-pane -D'
bind-key -n C-k if-shell "$is_vim" 'send-keys C-k' 'select-pane -U'
bind-key -n C-l if-shell "$is_vim" 'send-keys C-l' 'select-pane -R'
bind-key -n M-h if-shell "$is_vim" 'send-keys M-h' 'resize-pane -L 3'
bind-key -n M-j if-shell "$is_vim" 'send-keys M-j' 'resize-pane -D 3'
bind-key -n M-k if-shell "$is_vim" 'send-keys M-k' 'resize-pane -U 3'
bind-key -n M-l if-shell "$is_vim" 'send-keys M-l' 'resize-pane -R 3'
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
# Switch between tmux sessions
bind-key -T prefix L switch-client -l
bind -r C-h select-window -t :-
bind -r C-l select-window -t :+
# Resize pane shortcuts
bind -r H resize-pane -L 10
bind -r J resize-pane -D 10
bind -r K resize-pane -U 10
bind -r L resize-pane -R 10
# enable mouse support for switching panes/windows
setw -g mouse on
# set vi mode for copy mode
setw -g mode-keys vi
# more settings to make copy-mode more vim-like
unbind [
bind Escape copy-mode
unbind p
bind p paste-buffer
bind -T copy-mode-vi 'v' send -X begin-selection
# bind -T copy-mode-vi 'y' send -X copy-pipe-and-cancel "tmux save-buffer - | reattach-to-user-namespace pbcopy"
# bind-key -T copy-mode-vi 'y' send -X copy-pipe "kitty +kitten clipboard"
bind-key -T copy-mode-vi y if-shell "test ! -z $KITTY_WINDOW_ID" "send-keys -X copy-pipe 'kitty +kitten clipboard'" "send-keys -X copy-pipe 'pbcopy'"
# Buffers to/from Mac clipboard, yay tmux book from pragprog
bind C-c run "tmux save-buffer - | reattach-to-user-namespace pbcopy"
bind C-v run "tmux set-buffer $(reattach-to-user-namespace pbpaste); tmux paste-buffer"
# Make C-j display a selectable list of sessions
# bind C-j choose-tree
bind j split-window -v "tmux list-sessions | sed -E 's/:.*$//' | grep -v \"^$(tmux display-message -p '#S')\$\" | fzf --reverse | xargs tmux switch-client -t"
# C-g to interactively checkout git branches
bind g split-window -v "git branch --sort=-committerdate | grep -v '^\*' | fzf --reverse --info=inline | xargs git checkout"
# Move windows to the left/right with ctrl shift left/right
bind-key -n C-S-Left swap-window -t -1\; select-window -t -1
bind-key -n C-S-Right swap-window -t +1\; select-window -t +1
set-option -g focus-events on
##############################
### Color & Style Settings ###
##############################
source ~/Code/lua/neodotfiles/tmux/base16.sh
######## Tmux Plugins #########
# Save tmux sessions
set -g @plugin 'tmux-plugins/tmux-resurrect'
# Save (neo)vim sessions
set -g @resurrect-strategy-nvim 'session'
# Copy on tmux
set -g @plugin 'tmux-plugins/tmux-yank'
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'