aboutsummaryrefslogtreecommitdiff
path: root/.config/tmux/tmux.conf
blob: e426db1ca70f3aa422080b7098bd6c0353cb4d02 (plain)
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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
#  ████████╗███╗   ███╗██╗   ██╗██╗  ██╗
#  ╚══██╔══╝████╗ ████║██║   ██║╚██╗██╔╝
#     ██║   ██╔████╔██║██║   ██║ ╚███╔╝ 
#     ██║   ██║╚██╔╝██║██║   ██║ ██╔██╗ 
#     ██║   ██║ ╚═╝ ██║╚██████╔╝██╔╝ ██╗
#     ╚═╝   ╚═╝     ╚═╝ ╚═════╝ ╚═╝  ╚═╝
#――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
# Setting the prefix from C-b to C-s
unbind C-b
set -g prefix C-s
# Ensure that we can send Ctrl-S to other apps
bind C-s send-prefix
#set -g prefix M-Space
#set -g prefix C-Space
#setting the delay between prefix and command
set-option -sg escape-time 10
#set -s escape-time 0
# Vi mode in tmux, can confirm this working by pressing <prefix>:list-keys -T copy-mode-vi
# <prefix>[ to enter copy-mode to allow copying text or view history buffer, including search with / and ?. Screenwise vertical movemont with <ctrl-f> or <ctrl-b>
set-window-option -g mode-keys vi
# Reload the file with Prefix r
#bind r source-file ~/.tmux.conf \; display "Reloaded!"
bind r source-file ~/.config/tmux/tmux.conf \; display "Reloaded!"
#set -g history-limit 10000

# use the mouse
#set-window-option -g mode-mouse on
#set -g mouse-select-pane on
#set -g mouse-resize-pane on
#set -g mouse-select-window on

# pane movement
bind-key j command-prompt -p "send pane to:"  "join-pane -t '%%'"

# Pane resizing, default is D,U,L,R
bind -r H resize-pane -L 20
bind -r J resize-pane -D 20
bind -r K resize-pane -U 20
bind -r L resize-pane -R 20

bind-key M-j resize-pane -D 5
bind-key M-k resize-pane -U 5
bind-key M-h resize-pane -L 5
bind-key M-l resize-pane -R 5

# Hide a pane and bring it back with <prefix>! and <prefix>@ respectively
bind-key ! break-pane -d -n _hidden_pane
bind-key @ join-pane -s $.0
# enable activity alerts
#setw -g monitor-activity on
#set -g visual-activity on

# Update the status bar every sixty seconds
#set -g status-interval 60

# set colors for the active window
#setw -g window-status-current-fg white
#setw -g window-status-current-bg red
#setw -g window-status-current-attr bright
#set -g status-style fg="#000000",bg="#53E2AE"
#set -g pane-active-border-style bg=default,fg="#fe8019"
#set -g pane-border-style fg="#53E2AE"

## COLOUR (Solarized light)

## default statusbar colors
#set-option -g status-bg default
#set-option -g status-fg green
#set-option -g status-attr default
#
## default window title colors
#set-window-option -g window-status-fg magenta
#set-window-option -g window-status-bg default
#set-window-option -g window-status-attr dim
#
#set -g status-left-length 85
#set -g status-left "#[fg=yellow bg=default]#h #[fg=blue] #S #[fg=yellow] #I "
#set -g window-status-current-format "#[fg=black,bold bg=default]│#[fg=white bg=cyan]#W#[fg=black,bold bg=default]│"
#set -g status-right "#[fg=magenta] #[bg=gray] %b %d %Y %l:%M %p"
#set -g status-justify centre


# active window title colors
#set-window-option -g window-status-current-fg cyan 
#set-window-option -g window-status-current-bg default
#set-window-option -g window-status-current-attr bright


# pane border
# set-option -g pane-border-fg black
# set-option -g pane-border-bg black
# set-option -g pane-active-border-fg red
# set-option -g pane-active-border-bg default
# allow 'autoread' to work in neovim by focus events
# focus events enabled for terminals that support them
set-option -g focus-events on

# super useful when using "grouped sessions" and multi-monitor setup
setw -g aggressive-resize on



set -g mouse on

# Vi mode in tmux, can confirm this working by pressing <prefix>:list-keys -T copy-mode-vi
# <prefix>[ to enter copy-mode to allow copying text or view history buffer, including search with / and ?. Screenwise vertical movemont with <ctrl-f> or <ctrl-b>
set-window-option -g mode-keys vi


# change selection <space> and enter to vi keybinding
#bind-key -T copy-mode-vi 'v' send -X begin-selection
#bind-key -T copy-mode-vi 'y' send -X copy-selection-and-cancel

# X clipboard integration
# Vim style
#bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "xclip -i -sel clip > /dev/null"

#for copying to sys clipboard
#bind -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel "xclip -i -f -selection primary | xclip -i -selection clipboard"
#bind -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel "xclip -i -f -selection primary | xclip -i -selection clipboard"
#bind -T copy-mode-vi C-c send-keys -X copy-pipe-and-cancel "xclip -i -f -selection primary | xclip -i -selection clipboard"

# map copy mode to ctrl+alt+v
bind-key -n 'M-v' copy-mode

bind-key -T copy-mode-vi v send -X begin-selection

if-shell -b 'echo $XDG_SESSION_TYPE | grep -q x11' "\
    bind-key -T copy-mode-vi 'y' send-keys -X copy-pipe-and-cancel 'xclip -in -selection clipboard > /dev/null'; \
    bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel 'xclip -in -selection clipboard > /dev/null'; \
    bind-key C-M-v run 'xclip -out -selection clipboard | tmux load-buffer - ; tmux paste-buffer'"

if-shell -b 'echo $XDG_SESSION_TYPE | grep -q wayland' "\
    bind-key -T copy-mode-vi 'y' send-keys -X copy-pipe-and-cancel 'wl-copy'; \
    bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel 'wl-copy'; \
    bind-key C-p run 'wl-paste --no-newline | tmux load-buffer - ; tmux paste-buffer'" "\
    \
    bind-key -T copy-mode-vi 'y' send-keys -X copy-pipe-and-cancel 'cat - >/dev/clipboard'; \
    bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel 'cat - >/dev/clipboard'; \
    bind-key C-M-v run 'cat /dev/clipboard | tmux load-buffer - ; tmux paste-buffer'"




# Vim style copy to clipboard
#bind-key p run "xclip -o -sel clip | tmux load-buffer - ; tmux paste-buffer"


# Change split <Prefix>% and <Prefix>" to <Prefix>h and <Prefix>v and change current working directory
bind v split-window -h -c "#{pane_current_path}"
bind h split-window -v -c "#{pane_current_path}"


# smart pane switching with awareness of vim splits
bind -n C-h run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-h) || tmux select-pane -L"
bind -n C-j run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-j) || tmux select-pane -D"
bind -n C-k run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-k) || tmux select-pane -U"
bind -n C-l run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-l) || tmux select-pane -R"
#bind -n C-\ run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys 'C-\\') || tmux select-pane -l"

# use prefix + l to clear terminal
bind C-l send-keys 'C-l'
## set the default TERM
#set-option -g default-terminal "screen-256color"
#set-option -g default-terminal "tmux-256color"
#set -g default-terminal screen
# update the TERM variable of terminal emulator when creating a new session or attaching a existing session
#set -g update-environment 'DISPLAY SSH_ASKPASS SSH_AGENT_PID SSH_CONNECTION WINDOWID XAUTHORITY TERM'
# determine if we should enable 256-colour support
#if "[[ ${TERM} =~ 256color || ${TERM} == fbterm ]]" 'set -g default-terminal screen-256color'
#set -g default-terminal "tmux-256color"
#set -ga terminal-overrides ",xterm-256color:Tc"
#set-option -g default-terminal "tmux-256color"
set-option -sa terminal-overrides ",tmux-256color:Tc"
#set-option -sa terminal-overrides ",xterm*:Tc"
set-option -sa terminal-overrides ",xterm*:Tc,alacritty*:Tc"
# Enable RGB colour if running in xterm(1)
#set-option -sa terminal-overrides ",xterm*:Tc"
#set -ga terminal-overrides ",*256col*:Tc"

## Detach from current session
#bind -n M-d detach-client
#
## Popup scratch session
#bind -n M-g display-popup -E "tmux new-session -A -s scratch"
#
## non-popup
#bind C-j new-window -n "session-switcher" "\
#    tmux list-sessions -F '#{?session_attached,,#{session_name}}' |\
#    sed '/^$/d' |\
#    fzf --reverse --header jump-to-session --preview 'tmux capture-pane -pt {}'  |\
#    xargs tmux switch-client -t"
## popup
#bind C-j display-popup -E "\
#    tmux list-sessions -F '#{?session_attached,,#{session_name}}' |\
#    sed '/^$/d' |\
#    fzf --reverse --header jump-to-session --preview 'tmux capture-pane -pt {}'  |\
#    xargs tmux switch-client -t"
#bind -n M-f display-popup -E "\
#    tmux list-sessions -F '#{?session_attached,,#{session_name}}' |\
#    sed '/^$/d' |\
#    fzf --reverse --header jump-to-session --preview 'tmux capture-pane -pt {}'  |\
#    xargs tmux switch-client -t"
#
#bind -n M-? list-keys
#bind -n M-1 select-window -t :=1
#bind -n M-2 select-window -t :=2
#bind -n M-3 select-window -t :=3
#bind -n M-4 select-window -t :=4
#bind -n M-5 select-window -t :=5
#bind -n M-6 select-window -t :=6
#bind -n M-7 select-window -t :=7
#bind -n M-8 select-window -t :=8
#bind -n M-9 select-window -t :=9
#bind -n M-0 select-window -t :=0

# Colors for pane borders(default)
setw -g pane-border-style fg=white
setw -g pane-active-border-style fg=green

# Active pane normal, other shaded out
setw -g window-style fg=colour240
setw -g window-active-style fg=white


#set -g focus-events on
#set -g status-style bg=default
# Set the position of window lists
#set -g status-justify centre
# Set the status bar position
set -g status-position bottom # [top, bottom]
set -g status on
set -g status-interval 1


#set-option -g status-style bg=default
set -g status-style fg=#50fa7b,bg=default
#set -g status-style fg=DeepSkyBlue1,bg=black
#set -g status-style fg=black,bg=gray

#set -g status-left-style default
# Display the session name
#set -g status-left "#[fg=green] ❐ #S #[default]"

## Left
#set -g status-left ''
set -g status-left-length 60
set -g status-left "#[bg=#50fa7b,fg=black] ❐ #S #( ~/.config/tmux/left-status.sh ) #[fg=#50fa7b,bg=default]"
#bind o run-shell "tmux-toggle-option.sh set-option status-left on off"
#bind o set-option -g status-left "#[bg=#50fa7b,fg=black] ❐ #S #[fg=#50fa7b,bg=default]" \; display-message 'Status-left #{?status,off,on}'
#set set-option status-left
#bind o set-option status-left "#[bg=#50fa7b,fg=black] ❐ #S #[fg=#50fa7b,bg=default]" # toggle left-status script off
bind o run-shell "if [[ `tmux show-options -g status-left "#[bg=#50fa7b,fg=black] ❐ #S #( ~/.config/tmux/left-status.sh ) #[fg=#50fa7b,bg=default]"; then set -g status-left "#[bg=50fa7b,fg=black] ❐ #S #[fg=#50fa7b,bg=default]" else set -g status-left "#[bg=#50fa7b,fg=black] ❐ #S #( ~/.config/tmux/left-status.sh ) #[fg=#50fa7b,bg=default]" fi
bind C-o set-option status-left "#[bg=#50fa7b,fg=black] ❐ #S #( ~/.config/tmux/left-status.sh ) #[fg=#50fa7b,bg=default]" # toggle left status script on
#set -g status-left "#[fg=DeepSkyBlue1] ❐ #S #( ~/.config/tmux/left-status.sh )"
#set -g status-left "#[fg=black] ❐ #S #( ~/.config/tmux/left-status.sh )"

# Highlight the current window.
setw -g window-status-current-style fg=#50fa7b,bg=default,bright
#setw -g window-status-current-style fg=DeepSkyBlue1,bg=black,bright
#setw -g window-status-current-style fg=color235,bg=silver,bright
set -g window-status-current-format ' #I:#W '
#set -g status-format[0] '#[align=left] ❐ #S #( ~/.config/tmux/left-status.sh )#[align=absolute-centre]#[list=on] #I #W #[nolist]#[align=right] %H:%M %d-%m-%Y #H '
set -g status-justify absolute-centre
## Right
# Set right side status bar length and style
set-option -g status-right ""
set -g status-right-length 60
#set -g status-right-length 140
#set -g status-right-style default
#set -ag status-right "#[fg=black] %H:%M %d-%m-%Y #H "
set -ag status-right "#[fg=#50fa7b,bg=default] #{?client_prefix,#[reverse] Prefix #[noreverse] ,}     #[bg=default,fg=#50fa7b]#[bg=#50fa7b,fg=black]#( ~/.config/tmux/right-status.sh ) %H:%M | %d-%b-%y "
#set -g status-right "#(vmstat -SM 1 2 | awk 'END {print \"cpu:\"100-$15\"%\" \" mem:\"512-$4-$5-$6\"M\"}')#[default] %R"
#set -g status-right "#[fg=green] #22T | #(top -l 2 -FR -n 0 | egrep 'CPU|PhysMem' | awk 'FNR==3{print $8+$10}FNR==4{print $8}' ORS=%%/ | sed 's/..$//')/#(du -hs /var/vm | awk '{print $1}') | %a %b %d %Y %H:%M"
#set -ag status-right "#[fg=DeepSkyBlue1] #( ~/.config/tmux/right-status.sh ) %H:%M  %d-%m-%Y #H "
#set -ag status-right "#[fg=black] #( ~/.config/tmux/right-status.sh ) %H:%M  %d-%m-%Y #H "

# list of plugins
set -g @plugin 'tmux-plugins/tpm'
#set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'tmux-plugins/tmux-continuum'
set -g @plugin 'christoomey/vim-tmux-navigator'
#set -g @plugin 'tmux-plugins/tmux-yank'


# Plugins settings
# Plugin to save and restore tmux sessions after restart
# * Save with: prefix + Ctrl-s
# * Restore with: prefix + Ctlr-r
  # restore vim and nvim sessions as well
  # for vim
  set -g @resurrect-strategy-vim 'session'
  # for neovim
  set -g @resurrect-strategy-nvim 'session'
# Automatic restore
  set -g @continuum-restore 'on'
# Change default save and restore keybindings
  set -g @resurrect-save 'W'
  set -g @resurrect-restore 'E'
#  set -g @continuum-boot 'on'
## Restore Panes
#  set -g @resurrect-capture-pane-contents 'on'
# This a hook for tmux-resurrect which tells it to kill session 0 before restoring the panels
set -g @resurrect-hook-pre-restore-pane-processes 'tmux switch-client -n && tmux kill-session -t=0'
# plugin uninstall
   # Delete or comment out the plugin in .tmux.conf.
   # Press <prefix> + alt + u to remove the plugin.
# TMUX plugin manager (keep at the bottom of tmux.conf)
#run -b '~/.tmux/plugins/tpm/tpm'
run -b '~/.config/tmux/plugins/tpm/tpm'