-
Notifications
You must be signed in to change notification settings - Fork 1
/
tmux.conf
128 lines (100 loc) · 4.34 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
# default tmux key
unbind-key C-b
set -g prefix C-a
# force a reload of the config file
unbind-key r
bind-key r source-file ~/.tmux.conf\; display "Reloaded conf."
# the TERM variable reported by tmux to applications inside tmux
set -g default-terminal "tmux-256color"
# enable truecolour. check with nvim :checkhealth
set -sa terminal-overrides ",alacritty*:RGB"
set -sa terminal-overrides ",xterm*:Tc"
# enable strikethrough
set -as terminal-overrides ",*:smxx=\e[9m"
# https://github.com/ojroques/nvim-osc52/pull/25
set -g allow-passthrough on
# https://github.com/neovim/neovim/wiki/FAQ#esc-in-tmux-or-gnu-screen-is-delayed
set -s escape-time 0
# vim auto-read
set -g focus-events on
# scrollback history limit
set -g history-limit 10000
# start windows from 1
set -g base-index 1
# renumber windows on delete
set -g renumber-windows on
# mouse mode
set -g mouse on
# shift click to open urls
# colors
color_green='#98c379'
color_blue='#61afef'
color_magenta='#c678dd'
color_bg='#31353F'
color_grey='#3e4452'
# separators
lsep=''
rsep=''
# border style
set -g pane-border-style fg=$color_grey
set -g pane-active-border-style fg=$color_grey
# message style
set -g message-style fg=$color_bg,bg=$color_green
set -g message-command-style fg=$color_bg,bg=$color_magenta
# status bar
set -g status on
set -g status-position bottom
set -g status-justify left
set -g status-style fg=default,bg=$color_bg
prompt_color="#{?client_prefix,$color_magenta,$color_blue}"
prompt_style="#[bg=$prompt_color fg=$color_bg bold]"
prompt_style_end="#[bg=$color_bg fg=$prompt_color]"
set -g status-left "$prompt_style TMUX $prompt_style_end$lsep"
window_style="#[bg=$color_green fg=$color_bg bold]"
window_style_end="#[bg=$color_bg fg=$color_green]"
set -g window-status-format " #I #W \\"
set -g window-status-current-format "$window_style$lsep#{?window_zoomed_flag, #W , #I #W }$window_style_end$lsep"
date_style="#[bg=$color_grey,fg=default]"
date_format="%d/%m/%Y"
date_status="#[fg=$color_grey]$rsep$date_style $date_format"
time_style="#[bg=$color_green,fg=$color_bg bold]"
time_format="%R"
time_status="#[fg=$color_grey, fg=$color_green]$rsep$time_style $time_format"
set -g status-right "#( ~/dotfiles/tmux/pair-status.sh )$date_status $time_status "
set -g status-right-length 46
# hide satus bar unless there are multiple windows
# https://www.reddit.com/r/tmux/comments/90cm3w/help_how_to_show_status_if_number_of_windows_is/
set-hook -g window-linked "if -F '#{==:#{session_windows},1}' 'set -g status off' 'set -g status on'"
set-hook -g window-unlinked "if -F '#{==:#{session_windows},1}' 'set -g status off' 'set -g status on'"
# fullscreen a pane temporarily, 'z' again to exit (or another tmux command).
# toggles the status on even if there is only one window
is_zoomed="tmux list-panes -F '#F' | grep -q Z"
one_window="tmux list-windows | wc -l | grep -q 1"
bind-key z resize-pane -Z \;\
if-shell $is_zoomed 'set -g status on' 'if-shell $one_window "set -g status off"'
# key bindings
# 'c' to create a new window. tmux rename-window can be used to name it after
# 's' to search through windows and panes.
# 'n' to cycle through windows, a number can also be used for a specific window
# 'space' can be use to cycle through preset layouts. this is the best option to re-arrange things
# '[' and ']' can be used to move/swap a pane
# find in buffer. (Search up) vim like search (n to cycle)
bind-key / copy-mode \; send-key ?
# splitting windows
unbind-key %
bind-key - split-window -v -c '#{pane_current_path}'
bind-key _ split-window -v -c '#{pane_current_path}'
bind-key | split-window -h -c '#{pane_current_path}'
bind-key '\' split-window -h -c '#{pane_current_path}'
# faster resizing
bind-key -r -T prefix C-Up resize-pane -U 5
bind-key -r -T prefix C-Down resize-pane -D 5
bind-key -r -T prefix C-Left resize-pane -L 5
bind-key -r -T prefix C-Right resize-pane -R 5
# 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-Left if-shell "$is_vim" 'send-keys C-Left' 'select-pane -L'
bind-key -n C-Down if-shell "$is_vim" 'send-keys C-Down' 'select-pane -D'
bind-key -n C-Up if-shell "$is_vim" 'send-keys C-Up' 'select-pane -U'
bind-key -n C-Right if-shell "$is_vim" 'send-keys C-Right' 'select-pane -R'