-
Notifications
You must be signed in to change notification settings - Fork 0
/
tmux.conf
177 lines (135 loc) · 5.35 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
#------------#
#- Settings -#
#------------#
# Use 256 colors
# set -g default-terminal "tmux-256color"
# set -g default-terminal "xterm-256color"
set -g default-terminal screen-256color
set -ag terminal-overrides ",xterm-256color:RGB"
# Increase scrollback buffer size
set -g history-limit 50000
# tmux messages are displayed for 4 seconds
set -g display-time 4000
# refresh 'status-left' and 'status-right' more often
set -g status-interval 5
# super useful when using "grouped sessions" and multi-monitor setup
setw -g aggressive-resize on
# sends focus events for stuff like vim
set -g focus-events on
# Use zsh as default shell
# set -g default-shell /bin/zsh
# Set prefix to be C-a instead of C-b
set -g prefix C-a
unbind C-b
# Make more responsive
set -s escape-time 0
# Set base index for windows to 1 instead of 0
set -g base-index 1
# Set the base index for panes to 1 instead of 0
setw -g pane-base-index 1
setw -g mode-keys vi
set-window-option -g allow-rename off
# copy to macOS clipboard
if -b 'command -v pbcopy > /dev/null 2>&1' 'bind y run -b "tmux save-buffer - | pbcopy"'
if -b 'command -v reattach-to-user-namespace > /dev/null 2>&1' 'bind y run -b "tmux save-buffer - | reattach-to-user-namespace pbcopy"'
# copy to X11 clipboard
if -b 'command -v xsel > /dev/null 2>&1' 'bind y run -b "tmux save-buffer - | xsel -i -b"'
if -b '! command -v xsel > /dev/null 2>&1 && command -v xclip > /dev/null 2>&1' 'bind y run -b "tmux save-buffer - | xclip -i -selection clipboard >/dev/null 2>&1"'
#----------------#
#- Key mappings -#
#----------------#
# Reload tmux config
bind r source-file ~/.tmux.conf\; display "Reloaded!"
# Ensure that we can send prefix to other apps
bind C-a send-prefix
# Splitting panes with | and -
bind = split-window -h
bind - split-window -v
# Moving between panes with vim mappings
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
# Cycle through windows
bind -r C-h select-window -t :-
bind -r C-l select-window -t :+
# Resize panes with vim mappings
bind -r H resize-pane -L 5
bind -r J resize-pane -D 5
bind -r K resize-pane -U 5
bind -r L resize-pane -R 5
# Vim mappings for copy mode
bind Escape copy-mode
bind-key -T copy-mode-vi v send -X begin-selection
bind-key -T copy-mode-vi y send -X copy-selection
unbind p
bind p paste-buffer
# Smart pane switching with awareness of Vim splits.
# See: https://github.com/christoomey/vim-tmux-navigator
is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
| grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"
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"
bind-key -n 'C-\' if-shell "$is_vim" "send-keys 'C-\\'" "select-pane -l"
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
#----------------#
#- Color Scheme -#
#----------------#
# dims inactive panes
set -g window-style 'bg=colour237'
set -g window-active-style 'bg=black'
set-option -g status "on"
set -g status-position bottom
# default statusbar color
set-option -g status-style fg=colour136,bg=colour237
# pane border
set-option -g pane-active-border-style fg=colour250 #fg2
set-option -g pane-border-style fg=colour237 #bg1
# message infos
set-option -g message-style bg=colour239,fg=colour223
# writing commands inactive
set-option -g message-command-style bg=colour239,fg=colour223
# pane number display
set-option -g display-panes-active-colour colour250
set-option -g display-panes-colour colour237
## Theme settings mixed with colors (unfortunately, but there is no cleaner way)
set-option -g status-justify "left"
set-option -g status-left-style none
set-option -g status-left-length "80"
set-option -g status-right-style none
set-option -g status-right-length "80"
set-window-option -g window-status-separator ""
# Left Status
set-option -g status-left "#[fg=colour248, bg=colour241] ❐ #S #[default]"
set -ag status-left "#[fg=color248,bg=colour241]#(pmset -g batt | tail -1 | awk '{print $3}' | tr -d ';') #[default]"
# Right status
# set-option -g status-right "#[fg=colour180,bg=colour237,bright] #(top -l 1 | grep -E "^CPU" | sed 's/.*://') #[default]"
set-option -g status-right "#[fg=colour180,bg=colour237,bright] #[default]"
set -ag status-right "#[fg=white,bg=default] %a %d #[default]"
set -ag status-right "#[fg=colour172,bright,bg=default] ⌚︎%H:%M#[default]"
# Window Status
# Set the inactive window color and style
set-option -g window-status-style fg=colour244,bg=default
set-option -g window-status-format ' #I #W '
# Set the active window color and style
set-option -g window-status-current-style fg=black,bg=colour136
set-option -g window-status-current-format ' #I #W '
#-----------#
#- Plugins -#
# ----------#
# Ensures uninterruped tmux usage
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @resurrect-strategy-nvim 'session'
set -g @plugin 'tmux-plugins/tmux-continuum'
set -g @continuum-boot-options 'alacritty'
# Add utils for sessions
set -g @plugin 'tmux-plugins/tmux-sessionist'
# Open helpers in tmux
set -g @plugin 'tmux-plugins/tmux-open'
run -b '~/.tmux/plugins/tpm/tpm'