-
Notifications
You must be signed in to change notification settings - Fork 3
/
tmux.conf
193 lines (158 loc) · 8.25 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
184
185
186
187
188
189
190
191
192
193
# Tmux Cheatsheets:
# - https://devhints.io/tmux
# - https://gist.github.com/MohamedAlaa/2961058
## Terminal type configuration
# https://unix.stackexchange.com/a/171900
# https://github.com/tmux/tmux/issues/1246
set-option -g default-shell $SHELL
set -g default-terminal "screen-256color"
# favor tmux-256color over screen-256color - you get italic! (https://github.com/gpakosz/.tmux/blob/master/.tmux.conf)
if 'infocmp -x tmux-256color > /dev/null 2>&1' 'set -g default-terminal "tmux-256color"'
# favor RGB over Tc for tmux 3.2 or later - https://github.com/tmux/tmux/wiki/FAQ#how-do-i-use-rgb-colour
set-option -ga terminal-overrides ",*-256color*:RGB"
set-option -ga terminal-overrides ",alacritty:RGB"
# https://github.com/chriskempson/base16-shell/pull/214
set -g allow-passthrough on
# less delay with tmux key bindings
set -s escape-time 10
# window index start from 1 instead 0
set -g base-index 1
# pane index start from 1 instead 0
setw -g pane-base-index 1
# let fzf pop up on temp panel
FZF_TMUX=1
# to make sure something like fpp to pick up nvim instead of whatever the default
EDITOR=nvim
# if run as "tmux attach", create a session if one does not already exist
new-session -n $HOST
# position to top
set -g status-position top
# use OSC 52 - https://github.com/tmux/tmux/wiki/Clipboard
# also read https://medium.com/free-code-camp/tmux-in-practice-integration-with-system-clipboard-bcd72c62ff7b
set -g set-clipboard on # test via `printf "\033]52;c;$(printf "%s" "hello" | base64)\a"`
## List of plugins
# this allows installing other plugins `prefix I` to install plugins after listing them here
set -g @plugin 'tmux-plugins/tpm'
# A set of tmux options that should be acceptable to everyone.
set -g @plugin 'tmux-plugins/tmux-sensible'
# allows users to select actions from a customizable popup menu 🧰
set -g @plugin 'alexwforsythe/tmux-which-key'
# indicate modes you are in (normal/prefix, copy/insert)
set -g @plugin 'dominikduda/tmux_mode_indicator'
set -g @tmux_mode_indicator_left_edge_character ""
set -g @tmux_mode_indicator_separator "✤"
set -g @tmux_mode_indicator_background "colour110"
set -g @tmux_mode_indicator_right_edge_character ""
set -g @tmux_mode_indicator_right_edge_character_fg "colour0"
set -g @tmux_mode_indicator_left_edge_character_bg "colour0"
set -g @tmux_mode_indicator_after_interpolation_bg "colour0"
set -g @tmux_mode_indicator_after_interpolation_fg "colour0"
set -g @tmux_mode_indicator_prefix_pressed_bg "colour110"
set -g @tmux_mode_indicator_prefix_pressed_fg "colour124"
set -g @tmux_mode_indicator_copy_mode_bg "colour110"
set -g @tmux_mode_indicator_copy_mode_fg "colour122"
# allowing to navigate with C-hjkl between panes
# set -g @plugin 'christoomey/vim-tmux-navigator' - now I'm using my own with below;
# based on https://github.com/christoomey/vim-tmux-navigator?tab=readme-ov-file#add-a-snippet
# but with the modification to let also zellij to handle the keys
# since I use zellij within Tmux and https://github.com/hiasr/vim-zellij-navigator with zellij
# also pass through to ssh as well as zellij
is_zellij="ps -o state= -o comm= -t '#{pane_tty}' \
| grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(zellij|ssh)$'"
# let zellij's muscle memory also works for tmux when there is no zellij to control `send-keys -K` does the magic
bind-key -n 'C-b' if-shell "$is_zellij" { send-keys C-b } { send-keys -K C-a }
is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
| grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|l?n?vim?x?|fzf)(diff)?$'"
# in case it's zellij, execute both select-pane and send-keys as I prefer both action to happens than no action happens at all
bind-key -n 'C-h' if-shell "$is_zellij" { send-keys C-h; select-pane -L } {
# this is same as the vim-tmux-navigator
if-shell "$is_vim" {send-keys C-h} {select-pane -L}
}
bind-key -n 'C-j' if-shell "$is_zellij" { send-keys C-j; select-pane -D } {
if-shell "$is_vim" {send-keys C-j} {select-pane -D}
}
bind-key -n 'C-k' if-shell "$is_zellij" { send-keys C-k; select-pane -U } {
if-shell "$is_vim" {send-keys C-k} {select-pane -U}
}
bind-key -n 'C-l' if-shell "$is_zellij" { send-keys C-l; select-pane -R } {
if-shell "$is_vim" {send-keys C-l} {select-pane -R}
}
# `prefix f` to select a file to open from current pane
set -g @plugin 'tmux-plugins/tmux-fpp'
set -g @fpp-path "${XDG_CONFIG_HOME}/dfs-rhc/bin/path/default/wrapped-fpp"
# `prefix u` to select a url to open from current pane
set -g @plugin 'tmux-plugins/tmux-urlview'
# allowing you to copy to the system clipboard (not with OSC 52)
set -g @plugin 'tmux-plugins/tmux-yank'
# allowing you to have better mouse mode
set -g @plugin 'nhdaly/tmux-better-mouse-mode'
# `prefix tsv` to manipulate panes
set -g @plugin 'jabirali/tmux-tilish'
# allowing you to move and resize panes via `prefix (shift +) hjkl`
set -g @plugin 'tmux-plugins/tmux-pain-control'
# `prefix j` to jump to text
# set -g @plugin 'schasse/tmux-jump'
# replacing tmux-jump since `tmux-easymotion` uses python and `tmux-jump` uses ruby;
# and my environment very likely have python already but unlikely to have ruby by default
set -g @plugin 'ddzero2c/tmux-easymotion'
set -g @easymotion-key 'j' # trigger with `prefix j`
# `prefix tab` to toggle looking at files as tree in current pane
set -g @plugin 'tmux-plugins/tmux-sidebar'
## disabling until I really need it and know how to set up properly
# allowing saving and restoring sessions working together with `tmux-continuum`
# set -g @plugin 'tmux-plugins/tmux-resurrect'
# set -g @plugin 'tmux-plugins/tmux-continuum'
# set -g @continuum-restore 'on'
# allowing a use of tmux-themepack
set -g @plugin 'jimeh/tmux-themepack'
# powerline theme
set -g @powerline-color-grey-1 colour0 # to make background "clear"
set -g @themepack 'powerline/block/cyan'
# Enable mouse control (clickable windows, panes, resizable panes)
set -g focus-events on
set -g mouse on
# customizing via tmux-better-mouse-mode
set -g @emulate-scroll-for-no-mouse-alternate-buffer on
set -g @scroll-speed-num-lines-per-scroll "1"
# comment out this whole chunk for now since somehow this is not necessary to me (undercurl works without it)
# and also this even brings "too much attention" to SpellBad with red undercurl by default at least with with alacritty
#
# ## undercurl support - https://evantravers.com/articles/2021/02/05/curly-underlines-in-kitty-tmux-neovim/
# ## one use case - for my neovim SpellBad highlight to work as currently it's `cterm=undercurl gui=undercurl guisp=#dc322f`
# # undercurl support
# set -as terminal-overrides ',*:Smulx=\E[4::%p1%dm'
# # underscore colours - needs tmux-3.0
# set -as terminal-overrides ',*:Setulc=\E[58::2::%p1%{65536}%/%d::%p1%{256}%/%{255}%&%d::%p1%{255}%&%d%;m'
# Enable vi mode - https://sanctum.geek.nz/arabesque/vi-mode-in-tmux/
set-window-option -g mode-keys vi # e.g. navigating session/windows with vi key bindings
bind-key -T copy-mode-vi 'v' send -X begin-selection
bind-key -T copy-mode-vi 'y' send -X copy-selection-and-cancel
# remap prefix from 'C-b' to 'C-a'
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix
# split panes using | and -
unbind '"'
unbind %
bind / split-window -h -c "#{pane_current_path}"
bind - split-window -v -c "#{pane_current_path}"
# I actually don't like opening new window with current path so disable for now.
# bind c new-window -c "#{pane_current_path}"
# reload config file (change file location to your the tmux.conf you want to use)
# now there is also tmux-autoreload at the bottom
bind r source-file ~/.tmux.conf
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'
# this must be after run tpm line
# set -g status-right '#[fg=colour235,bg=colour233]#[fg=colour240,bg=colour235]#(gitmux -cfg ~/.gitmux.conf "#{pane_current_path}")'
# instead of gitmux, display weather info for now
set -g status-right '#{tmux_mode_indicator}#(tmux-hud-r)'
set -g status-interval 10
# somehow this requires to run after setting the `status-right` above to be able to work properly
run-shell ~/.tmux/plugins/tmux_mode_indicator/tmux_mode_indicator.tmux
# this needs to be at the bottom
set-option -g @plugin 'b0o/tmux-autoreload'
# create a new session within another session
# ctrl + a :new -s <name>
# or ctrl + a :new-session -t <name>
# https://stackoverflow.com/questions/16398850/create-new-tmux-session-from-inside-a-tmux-session#comment47958386_21272658