-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexecutable_dot_tmux.conf
More file actions
157 lines (127 loc) · 5.73 KB
/
executable_dot_tmux.conf
File metadata and controls
157 lines (127 loc) · 5.73 KB
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
#set -g default-terminal "xterm-256color"
#set-option -ga terminal-overrides ",xterm-256color:Tc"
set -g default-terminal "screen-256color"
set-option -ga terminal-overrides ",screen-256color:Tc"
# enable mouse mode
set -g mouse on
# set CTRL + SPACE as prefix
unbind C-b
set -g prefix C-Space
bind C-Space send-prefix
# reload
bind C-r source-file ~/.tmux.conf \; display "Config reloaded"
# Start windows and panes at 1, not 0
set -g base-index 1
set -g pane-base-index 1
set-window-option -g pane-base-index 1
set-option -g renumber-windows on
# Use CRTL-hjkl keys without prefix key to switch panes
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
# '
# Shift arrow to switch windows
bind -n S-Left previous-window
bind -n S-Right next-window
bind r command-prompt -I "#{window_name}" "rename-window '%%'"
bind R command-prompt -I "#{session_name}" "rename-session '%%'"
# set vi-mode
set-window-option -g mode-keys vi
# keybindings
bind-key -n F4 copy-mode
bind-key -T copy-mode-vi v send-keys -X begin-selection
bind-key -T copy-mode-vi C-v send-keys -X rectangle-toggle
bind-key -T copy-mode-vi y send -X copy-pipe-and-cancel 'xclip -in -selection clipboard'
# bind - and | to vertical and horizontal split pane
bind - split-window -v -c "#{pane_current_path}"
bind | split-window -h -c "#{pane_current_path}"
# source bash when starting tmux in order to load bashrc
set-option -g default-shell "/usr/bin/fish"
set-option -g default-command fish
# tmux sessionizer options
bind-key -r f run-shell "tmux neww tmux-sessionizer"
bind-key -r p display-popup -E "tmux-sessionizer"
bind-key -r M-1 run-shell "tmux neww tmux-sessionizer 0"
bind-key -r M-2 run-shell "tmux neww tmux-sessionizer 1"
bind-key -r M-3 run-shell "tmux neww tmux-sessionizer 2"
bind-key -r M-4 run-shell "tmux neww tmux-sessionizer 3"
# swich sessions via <prefix>C-s
# https://unix.stackexchange.com/a/342659
bind-key C-s \
if-shell "(($(tmux display -p '#{session_many_attached}')))" \
choose-session \
"run-shell \"tmux choose-session \\\"switch-client -t '%%'; kill-session -t '$(tmux display -p '#S')'\\\"\""
# nvim tmux navigation
# Smart pane switching with awareness of Vim splits.
# See: https://github.com/christoomey/vim-tmux-navigator
vim_pattern='(\S+/)?g?\.?(view|l?n?vim?x?|fzf)(diff)?(-wrapped)?'
is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
| grep -iqE '^[^TXZ ]+ +${vim_pattern}$'"
bind-key -n 'C-up' if-shell "$is_vim" 'send-keys C-up' 'resize-pane -U 5'
bind-key -n 'C-down' if-shell "$is_vim" 'send-keys C-down' 'resize-pane -D 5'
bind-key -n 'C-left' if-shell "$is_vim" 'send-keys C-left' 'resize-pane -L 5'
bind-key -n 'C-right' if-shell "$is_vim" 'send-keys C-right' 'resize-pane -R 5'
# bind -n C-up
# bind -n C-down resize-pane -D 5
# bind -n C-left resize-pane -L 5
# bind -n C-right resize-pane -R 5
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'
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'"
# set catpucchin flavor to mocha
set -g @catppuccin_flavour 'mocha'
# define tmux plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'dreamsofcode-io/catppuccin-tmux'
set -g @plugin 'tmux-plugins/tmux-yank'
run '~/.tmux/plugins/tpm/tpm'
# Feel free to NOT use this variables at all (remove, rename)
# this are named colors, just for convenience
color_orange="colour166" # 208, 166
color_purple="colour134" # 135, 134
color_green="colour076" # 070
color_blue="colour39"
color_yellow="colour220"
color_red="colour160"
color_black="colour232"
color_white="white" # 015
# This is a theme CONTRACT, you are required to define variables below
# Change values, but not remove/rename variables itself
color_dark="$color_black"
color_light="$color_white"
color_session_text="$color_blue"
color_status_text="colour245"
color_main="$color_orange"
color_secondary="$color_purple"
color_level_ok="$color_green"
color_level_warn="$color_yellow"
color_level_stress="$color_red"
color_window_off_indicator="colour088"
color_window_off_status_bg="colour238"
color_window_off_status_current_bg="colour254"
bind -T root F12 \
set prefix None \;\
set key-table off \;\
set status-style "fg=$color_status_text,bg=$color_window_off_status_bg" \;\
set window-status-current-format "#[fg=$color_window_off_status_bg,bg=$color_window_off_status_current_bg]$separator_powerline_right#[default] #I:#W# #[fg=$color_window_off_status_current_bg,bg=$color_window_off_status_bg]$separator_powerline_right#[default]" \;\
set window-status-current-style "fg=$color_dark,bold,bg=$color_window_off_status_current_bg" \;\
if -F '#{pane_in_mode}' 'send-keys -X cancel' \;\
refresh-client -S \;\
bind -T off F12 \
set -u prefix \;\
set -u key-table \;\
set -u status-style \;\
set -u window-status-current-style \;\
set -u window-status-current-format \;\
refresh-client -S
wg_is_keys_off="#[fg=$color_light,bg=$color_window_off_indicator]#([ $(tmux show-option -qv key-table) = 'off' ] && echo 'OFF')#[default]"
set -g status-right "$wg_is_keys_off #{sysstat_cpu} | #{sysstat_mem} | #{sysstat_loadavg} | $wg_user_host"