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
|
# Tmux configuration for vim-like keybindings
setw -g mode-keys vi
unbind [
bind Escape copy-mode
unbind p
bind p paste-buffer
bind-key -T copy-mode-vi 'v' send -X begin-selection
bind-key -T copy-mode-vi 'y' send -X copy-selection-and-cancel
# splitting windows: tmux definition of vertical/horizontal split is reversed
# to vim's
bind s split-window -v
bind v split-window -h
# vim-like resizing
bind < resize-pane -L 10
bind > resize-pane -R 10
bind + resize-pane -U 10
bind - resize-pane -D 10
# vim-like command prompt
bind : command-prompt
# Smart pane switching with awareness of vim splits
is_vim='echo "#{pane_current_command}" | grep -iqE "(^|\/)g?(view|n?vim?)(diff)?$"'
bind -n C-h if-shell "$is_vim" "send-keys C-h" "select-pane -L"
bind -n C-j if-shell "$is_vim" "send-keys C-j" "select-pane -D"
bind -n C-k if-shell "$is_vim" "send-keys C-k" "select-pane -U"
bind -n C-l if-shell "$is_vim" "send-keys C-l" "select-pane -R"
# TokyoNight colors for Tmux
set -g mode-style "fg=#7aa2f7,bg=#3b4261"
set -g message-style "fg=#7aa2f7,bg=default"
set -g message-command-style "fg=#7aa2f7,bg=default"
set -g pane-border-style "fg=#3b4261"
set -g pane-active-border-style "fg=#3b4261"
# top border style
set -g pane-border-format ""
setw -g pane-border-status bottom
# formatting and configuration for status text
set -g status-style "fg=#7aa2f7,bg=default"
setw -g window-status-activity-style "underscore,fg=#a9b1d6,bg=default"
setw -g window-status-separator ""
setw -g window-status-style "NONE,fg=#a9b1d6,bg=default"
set -g status-right "#{prefix_highlight} #[fg=#3b4261,bg=default,nobold,nounderscore,noitalics]#[fg=#7aa2f7,bg=#3b4261] %I:%M %p #[fg=#7aa2f7,bg=#3b4261,nobold,nounderscore,noitalics]#[fg=#1D202F,bg=#7aa2f7,bold]"
set -g status-left "#[fg=#1D202F,bg=#7aa2f7,bold] #S #[bg=#7aa2f7,bold]#[bg=default]"
set -g status-left-length 150
set -g status-right-length 150
set -g status-interval 5
set -g status-justify left
set -g status-position bottom
# window title
# tmux tab (window name) styling
set -g window-status-format "#[fg=#2a2e40]#[bg=#2a2e40,fg=#565d83] #I #W #[fg=#2a2e40,bg=default]"
set -g window-status-current-format "#[fg=#ffffff]#[fg=#1d202f,bg=#ffffff] #I #W #[fg=#ffffff,bg=default]"
# prevent auto window renaming once I renamed it
set -g allow-rename off
set -g history-limit 40000
# enable true color mode (on mac and linux)
# see https://github.com/tmux/tmux/issues/2665#issuecomment-825017707
# on mac, the terminfo must be updated as per https://gist.github.com/bbqtd/a4ac060d6f6b9ea6fe3aabe735aa9d95
set-option -gs default-terminal "tmux-256color"
set-option -gas terminal-overrides "*:Tc" # true color support
set-option -gas terminal-overrides "*:RGB" # true color support
set -as terminal-overrides ',*:Smulx=\E[4::%p1%dm' # undercurl support
set -as terminal-overrides ',*:Setulc=\E[58::2::%p1%{65536}%/%d::%p1%{256}%/%{255}%&%d::%p1%{255}%&%d%;m' # underscore colours - needs tmux-3.0
# https://github.com/neovim/neovim/wiki/FAQ#cursor-shape-doesnt-change-in-tmux
set -g -a terminal-overrides ',*:Ss=\E[%p1%d q:Se=\E[2 q'
# additional support for alacritty
set -as terminal-features ",alacritty*:RGB"
bind S display-popup -e -w 80% -h 80% nvim -c ":telescope tmux sessions quit_on_select=true"
bind W display-popup -E -w 80% -h 80% nvim -c ":Telescope tmux windows quit_on_select=true"
set -sg escape-time 0
set-option -g focus-events on
|