aboutsummaryrefslogtreecommitdiffstats
path: root/.tmux.conf
blob: e7265b0e9c203267132b9c4a453850e739fee87b (plain) (blame)
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
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'tmux-plugins/tmux-online-status'
set -g @plugin 'soyuka/tmux-current-pane-hostname'
set -g @plugin 'laktak/extrakto'
set -g @plugin 'tmux-plugins/tmux-copycat'
set -g @plugin 'schasse/tmux-jump'
set -g @plugin 'tmux-plugins/tmux-yank'
set -g @plugin 'wfxr/tmux-fzf-url'
set -g @plugin 'tmux-plugins/tmux-prefix-highlight'
set -g @plugin 'tmux-plugins/tmux-continuum'

set -g @continuum-restore 'on'
set -g @continuum-save-interval '15'

# set -g @plugin 'tmux-plugins/tmux-sidebar'
# set -g @resurrect-processes `ranger ssh w3mlastsession k9s top cointop newsboat irssi neomutt`
set -g @fzf-url-history-limit '2000'
set -g @fzf-url-fzf-options '-w 70% -h 70% --multi -0 --no-preview --border=sharp'

#unbindings -- these are reserved for vim use
unbind Up
unbind Down
unbind Left
unbind Right
unbind-key p
unbind-key n

# set -g automatic-rename on
# set -g renumber-windows on
# set -g- set-titles on

set-window-option -g automatic-rename on
set-option -g set-titles on
set -g focus-events on
# dont wait for escape
set -sg escape-time 0
# bind-key -g C-a last-window
# bind-key a send-prefix

set -g default-command /usr/bin/zsh
set -g default-shell /usr/bin/zsh
set -g default-terminal "st-256color"
set -s set-clipboard external

set-option -g prefix C-a
set -g status-interval 120
set-option -g history-limit 10000
set-option -g repeat-time 500
set -g display-time 0
set status-keys vi

#prefix highlight settings
set -g @prefix_highlight_show_copy_mode 'on'
set -g @prefix_highlight_copy_mode_attr 'fg=colour16,bg=yellow,bold'
set -g @prefix_highlight_prefix_prompt 'Wait'
set -g @prefix_highlight_copy_prompt 'Copy'
set -g @prefix_highlight_output_suffix ''

#online status options
# set -g @online_icon "ok"
# set -g @offline_icon "offline!"
set -g @online_icon "#[bg=colour25 fg=colour22]#[bg=colour22] "
set -g @offline_icon "#[bg=colour25 fg=colour1]#[bg=colour1] "

set -g @jump-key 's'

#move/panes panes and windows
# bind-key W choose-tree -Zw "swap-window -t '%%'"
# bind-key P choose-tree -Zw "swap-pane -t '%%'"
# bind-key C-M-w choose-tree -Zw "move-window -t '%%'"
# bind-key C-M-p choose-tree -Zw "move-pane -t '%%'"
# bind-key C-M-w command-prompt -p "Swap Current Window To? (e.g 3; 4; session_name:5)" "swap-window -t '%%'"
# bind-key C-M-p command-prompt -p "Swap Current Pane To? (e.g 2.0; session_name:4.0)" "swap-pane -t '%%'"
bind-key M-p command-prompt -p "Move Current Pane To? (e.g 3.1; session_name:6.0)" "move-window -t '%%'"
bind-key M-w command-prompt -p "Move Current Window To? (e.g 3.1; session_name:6.0)" "move-pane -t '%%'"
#swap panes around
# bind-key -r -T prefix C-M-k select-pane -U \; swap-pane -t !
# bind-key -r -T prefix C-M-j select-pane -D \; swap-pane -t !
# bind-key -r -T prefix C-M-h select-pane -L \; swap-pane -t !
# bind-key -r -T prefix C-M-l select-pane -R \; swap-pane -t !

# hide a pane and bring it back again
bind-key ! break-pane -d -n _hidden_pane
bind-key @ join-pane -s $.0

bind-key p popup -w 80% -h 80% -E ksh
bind-key S popup -w 90% -h 90% -E env WWW_HOME=searx.terminaldweller.com /home/devi/w3m/w3m -o auto_image=FALSE -graph
# bind-key F popup -d ${pane_current_path} -w 90% -h 90% -E ranger --cmd cd $(tmux show -p '#{pane_current_path}')
bind-key F popup -d ${pane_current_path} -w 90% -h 90% -E ranger

#to support nested tmux sessions for ssh workflows
bind -T root F6 \
  set prefix None \;\
  set key-table off \;\
  if -F '#{pane_in_mode}' 'send-keys -X cancel' \;\
  refresh-client -S \;\

bind -T off F6 \
  set -u prefix \;\
  set -u key-table \;\
  refresh-client -S

wg_is_keys_off="#[fg=colour15,bg=colour63,bold]#([ $(tmux show-option -qv key-table) = 'off' ] && echo 'OFF')#[fg=colour24] #{?#{pane_ssh_connected},#[fg=colour63 bg=colour70],#[fg=colour63 bg=colour70]}#[default]"
# from christoomey's vim-tmux-nivagator
is_vim="ps -o state= -o comm= -t '#{pane_tty}' | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"
#key bindings
#do not use alt keybindings. because of the escape passed at the beginning of a alt keycode,
#zsh's vim mode's escape becomes slow since tmux will have to wait on keybindings beginning with escape.
bind | split-window -h
bind - split-window -v
bind -r k select-pane -U
bind -r j select-pane -D
bind -r h select-pane -L
bind -r l select-pane -R
# bind -n C-w-w select-pane -l
bind-key -Ttable1 'C-w' if-shell "$is_vim" 'send-keys C-w' 'select-pane -l'
bind-key -Troot 'C-w' if-shell "$is_vim" 'send-keys C-w' 'switch-client -Ttable1'
# bind -n S-Right next-window
# bind -n S-Left previous-window
bind -n C-k next-window
bind -n C-j previous-window
# bind -n M-Up select-pane -U
# bind -n M-Down select-pane -D
# bind -n M-Left select-pane -L
# bind -n M-Right select-pane -R
# bind -r C-k select-pane -U
# bind -r C-j select-pane -D
# bind -r C-h select-pane -L
# bind -r C-l select-pane -R
setw -g mode-keys vi
bind [ copy-mode
# bind -T copy-mode-vi 'v' send -X begin-selection
# set -s copy-command 'wl-copy'
set -s copy-command 'xsel -ib'
bind -T copy-mode-vi 'v' send -X copy-pipe
bind -T copy-mode-vi 'y' send -X copy-pipe-and-cancel
# bind -T copy-mode-vi 'y' send -X copy-selection-and-cancel "xsel -i --clipboard"
#bind -T copy-mode-vi 'V' rectangle-toggle
bind ] paste-buffer
bind Space choose-buffer
# bind C-l send-keys 'C-l'
bind -n C-h clear-history
bind P pipe-pane -o "cat >>~/.tmuxrecording/#W.log" \; display "Toggled logging to ~/#W.log"

#move windows
# bind-key -n C-S-Left swap-window -t -1
# bind-key -n C-S-Right swap-window -t +1
# bind-key -n M-S-j swap-window -t -1
# bind-key -n M-S-k swap-window -t +1
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

# Enable activity alerts.
setw -g monitor-activity off
set -g visual-activity off

# pane border style
set -g pane-active-border-style fg='#669933',bold
set -g pane-border-style fg='#0099ff'
set -g pane-border-status top
set -g pane-border-lines heavy
# set -g pane-border-format "#{pane_index}:#{s/sudo//:pane_current_command}"
set -g pane-border-format "#{pane_index}:#{pane_current_command}"

# message text
set -g message-style bg='#44475a',fg='#8be9fd'

set-option -g status on
# toggle the display of the statusbar
bind-key -n S-F6 set-option -g status
set-option -g status-justify "centre"
set-option -g status-left-length 120
set-option -g status-right-length 170

continuumStatus="#[fg=colour16 bg=colour70 bold]#(xkb-switch -p)#[nobold]#{?#{pane_ssh_connected},#[fg=colour70 bg=colour31],#[fg=colour70 bg=colour24]}"
sshStatus="#{?#{pane_ssh_connected},#[fg=colour15 bold],#[fg=colour15 nobold]}#U@#H#{?#{pane_ssh_connected},:#{pane_ssh_port}#[fg=colour31 bg=colour26],#[fg=colour24 bg=colour26]}"
set-option -g status-left "#{prefix_highlight}$wg_is_keys_off$continuumStatus$sshStatus#[nobold]#(/home/devi/scripts/tmux/vcs_info.sh)"
set-option -g status-right "#(/home/devi/scripts/tmux/date.sh)#{online_status}"
# set-option -g status-left ">>>"
# set-option -g status-right "<<<"

current_window_format="#{?window_zoomed_flag,#[fg=colour63#, bg=colour16]#[fg=colour63#, bg=colour16#, bold] Z #W #[fg=colour63#, bg=colour16],#[fg=colour255#, bg=colour16] #I #W #[fg=colour255#, bg=colour16]}"

set-window-option -g window-status-current-format $current_window_format
# set-window-option -g window-status-current-format "#[fg=colour255, bg=colour16]#[fg=colour255, bg=colour16] #I #W #[fg=colour255, bg=colour16]"
set -g status-bg colour16
set-window-option -g window-status-format "#[fg=colour32 bg=colour16]#[fg=colour255 bg=colour32]#I#[fg=colour32 bg=colour16]"
set-window-option -g window-status-separator ""

#run command on idle
#set -g lock-after-time 300
#set -g lock-command "cmatrix -C blue"
bind-key e copy-mode \; send-keys "?Error" C-m

#must be the last line
run '~/.tmux/plugins/tpm/tpm'