-
Notifications
You must be signed in to change notification settings - Fork 4
/
dot_tmux.conf.tmpl
171 lines (134 loc) · 5.79 KB
/
dot_tmux.conf.tmpl
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
# Amar Paul's tmux configuration!
# With help from a few sources -
# https://gist.github.com/v-yarotsky/2157908
# https://github.com/skwp/dotfiles/blob/master/tmux/tmux.conf
####
## Look and feel
####
{{ if (eq .chezmoi.os "darwin") -}}
# reattach to Quartz window server (commands like `open` or `subl`)
set-option -g default-command "reattach-to-user-namespace -l $SHELL"
{{- end }}
# Enable mouse mode and scrolling
# https://ryanfb.github.io/etc/2015/10/19/tmux_mouse_mode_on_el_capitan.html
set -g mouse on
##
# following block shouldn't be necessary with nhdaly/tmux-better-mouse-mode
#
#set-window-option -g alternate-screen off
# Check if copy-mode or any mouse flags, then send mouse events
# or check if we're in alternate screen end send navigation keys (up, down)
# bind -n WheelUpPane if-shell -Ft='#{?pane_in_mode,1,#{mouse_any_flag}}' \
# 'send -Mt=' 'if-shell -Ft= "#{alternate_on}" \
# "send -t= Up" "copy-mode -et= ; send -Mt="'
# bind -n WheelDownPane if-shell -Ft= '#{?pane_in_mode,1,#{mouse_any_flag}}' \
# 'send -Mt=' 'if-shell -Ft= "#{alternate_on}" \
# "send -t= Down" "send -Mt="'
##
# set first window to index 1 (not 0) to map more to the keyboard layout...
set-option -g base-index 1
set-window-option -g pane-base-index 1
set -g default-terminal "screen-256color" # 256 color tmux
set -g history-limit 100000 # scrollback buffer
set -sg escape-time 0 # No delay for escape key press
set -g focus-events on # for nvim autoread
set -sa terminal-features ',screen-256color:RGB' # for nvim termcolors
setw -g aggressive-resize on
# Colors, titles ideas (and Shift-switching) taken from:
# https://gist.github.com/paulrouget/cc3cf124e0789c5dc1d387c2180f132b
# https://www.reddit.com/r/unixporn/comments/5vke7s/osx_iterm2_tmux_vim/
# color status bar
set-option -g status on
set-option -g status-fg white
set-option -g status-bg default
set-option -g status-style default
# default simple look
set -g status-left '#[fg=colour232,bg=colour2] #S #[fg=colour2,bg=colour233,nobold,nounderscore,noitalics] '
setw -g window-status-format ' #(echo "#{pane_current_command}") '
setw -g window-status-current-format ' #(echo "#{pane_current_command}") '
setw -g window-status-current-style fg=red
# airline style
if-shell -b '[[ $EDITOR_LOOK == "carot" ]]' \
"set -g status-left '#[fg=colour232,bg=colour2] #S #[fg=colour2,bg=colour233,nobold,nounderscore,noitalics] '; \
setw -g window-status-current-format ' #(echo \"#{pane_current_command}\") '; \
setw -g window-status-current-style fg=red,bg=black; \
setw -g window-status-style fg=white,bg=black"
# ▏▎▍ block style
if-shell -b '[[ $EDITOR_LOOK == "block" ]]' \
"set -g status-left '#[fg=colour232,bg=colour2] #S ▏▎▌▊#[fg=colour2,bg=colour233,nobold,nounderscore,noitalics] '; \
setw -g window-status-format ' #(echo \"#{pane_current_command}\") ▊'; \
setw -g window-status-current-format '▊▌#(echo \"#{pane_current_command}\") ▊▉'; \
setw -g window-status-current-style fg=colour232,bg=red; \
setw -g window-status-style fg=black,bg=green"
set -g status-right ''
# need to update for linux with block/carot
#set -g status-right "#[fg=colour2,bg=colour233,nobold,nounderscore,noitalics]#[fg=colour232,bg=colour2] linux "
####
## Key bindings
####
# Copy/pasting
# Use vim keybindings in copy mode
# from https://robots.thoughtbot.com/tmux-copy-paste-on-os-x-a-better-future
setw -g mode-keys vi
# Setup 'v' to begin selection as in Vim, and 'y' to copy
bind-key -T copy-mode-vi v send -X begin-selection
{{ if (eq .chezmoi.os "darwin") -}}
bind-key -T copy-mode-vi y send -X copy-pipe "pbcopy"
{{ else if (eq .chezmoi.os "linux") -}}
bind-key -T copy-mode-vi y send -X copy-pipe "xclip -sel clipboard"
{{- end }}
# Update default binding of `Enter` to also use copy-pipe
# (don't think I need this)
#unbind -t vi-copy Enter
#bind -t vi-copy Enter copy-pipe "reattach-to-user-namespace pbcopy"
# change to ctrl+a prefix
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix
# better splitting (use ',' and '.')
unbind %
unbind ,
bind , split-window -h -c "#{pane_current_path}"
unbind '"'
bind . split-window -v -c "#{pane_current_path}"
# Create new windows
bind -n S-Down new-window -c "#{pane_current_path}"
bind c new-window -c "#{pane_current_path}"
# Destroy pane (will destroy window if last pane)
bind -n M-w kill-pane
# Pane resize in all four directions (without prefix)
bind -nr M-H resize-pane -L 5
bind -nr M-J resize-pane -D 5
bind -nr M-K resize-pane -U 5
bind -nr M-L resize-pane -R 5
# Show/hide status bar
bind -n S-Up set-option -g status
# Toggle through windows
bind -n S-Left previous-window
bind -n S-Right next-window
# Swap windows
bind -n C-S-Left swap-window -t -1 \; previous-window
bind -n C-S-Right swap-window -t +1 \; next-window
# Swap panes
unbind '{'
bind '{' swap-pane -D
unbind '}'
bind '}' swap-pane -U
# Reload config file
unbind r
bind r source-file ~/.tmux.conf \; display "Reloaded!"
# Plugins for tmux
set -g @plugin 'tmux-plugins/tmux-sessionist' # better mgmt of sessions
set -g @plugin 'tmux-plugins/tmux-resurrect' # save/restore tmux state
set -g @plugin 'nhdaly/tmux-better-mouse-mode' # better scrolling
set -g @plugin 'tmux-plugins/tmux-continuum' # automatic save/restore tmux state (depends on tmux-resurrect)
set -g @plugin 'tmux-plugins/tmux-open' # open urls from tmux (needed on current alacritty)
set -g @plugin 'christoomey/vim-tmux-navigator' # tmux/vim keybindings interop, pane movements
set -g @resurrect-save 'S'
set -g @resurrect-restore 'R'
set -g @resurrect-strategy-nvim 'session'
set -g @emulate-scroll-for-no-mouse-alternate-buffer 'on'
set -g @continuum-restore 'on'
set -g @open-S 'https://www.duckduckgo.com/?q='
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'