-
Notifications
You must be signed in to change notification settings - Fork 5
/
.tmux.conf
147 lines (124 loc) · 5.15 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
###--- Global options --- ###
# Don't wait for keystrokes after escape
set-option -sg escape-time 0
set -s escape-time 0
# Ensure focus events enabled for nvim/tmux
set-option -g focus-events on
# Ensure that tmux does not emit any beep sounds
# https://stackoverflow.com/questions/18843075/tmux-disable-beep-on-attach-detach
set -g bell-action any
set -g visual-bell off
# Reset Prefix
set -g prefix C-a
bind a send-prefix # for nested tmux sessions
# allow scrolling with mouse-wheel/pad
set -g mouse on
# basic settings
set -g allow-rename off # don't auto change my window names
set-window-option -g automatic-rename off # don't auto rename
set-window-option -g xterm-keys on # for vim
set-window-option -g mode-keys vi # vi key
set-window-option -g monitor-activity on
set -g default-terminal "screen-256color"
set -ag terminal-overrides ",xterm-256color:RGB"
###--- Status Bar ---###
set -g status-justify left
set -g status-right-length 60
set -g status-interval 5
# Follow i3 config for active/inactive colours
set -g pane-active-border-style bg=0,fg=colour13
set -g pane-border-style bg=0,fg=colour2
# don't invert colours for active windows by default (ill do this myself)
# https://unix.stackexchange.com/questions/120857/tmux-monitor-activity-change-highlight-color
set -g status-style fg=colour2,bg=colour0,none
# set-window-option -g window-status-style fg=colour2,bg=colour0,none
# set-window-option -g window-status-current-style fg=colour2,bg=colour0,none
set-window-option -g window-status-activity none
set -g window-status-format "#[fg=colour2,bg=colour0,nobold]<#I:#W>"
set -g window-status-current-format "#[fg=colour0,bg=colour13,bold]<#I:#W>"
set -g status-right "#[fg=colour2,bg=colour0,nobold]#(bar #{client_width}) %a %d %l:%M %p "
set -g status-left ""
###--- Unbindings ---###
#unbind [ # copy mode bound to escape key
unbind j
unbind C-b # unbind default leader key
unbind '"' # unbind horizontal split
unbind % # unbind vertical split
###--- Bindings ---###
bind r source-file ~/.tmux.conf \; display-message ".tmux.conf reloaded"
# Avoid confirmations when killing
bind Q kill-session
bind X kill-window
bind x kill-pane
#bind prefix + C-c to clear the terminal, since C-l is used for movement
bind C-c send-keys 'C-l'
# Windows
set-window-option -g window-status-current-style fg=white,reverse,bg=red
bind n next-window
bind N previous-window
bind C-a last-window # C-a C-a for last active window
bind A command-prompt "rename-window %%"
# Panes
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
bind BSpace split-window -v -c "#{pane_current_path}"
bind '\' split-window -h -c "#{pane_current_path}"
bind c new-window -c "#{pane_current_path}"
bind Space list-panes
bind Enter break-pane
# Resizing
bind C-h resize-pane -L 5
bind C-j resize-pane -D 5
bind C-k resize-pane -U 5
bind C-l resize-pane -R 5
# Selection and copy paste
bind v copy-mode
bind p paste-buffer
bind -T copy-mode-vi 'v' send -X begin-selection
bind -T copy-mode-vi 'V' send -X select-line
bind -T copy-mode-vi 'r' send -X rectangle-toggle
bind -T copy-mode-vi 'y' send -X copy-pipe-and-cancel "xclip -in -selection clipboard"
# Layouts
bind o next-layout
bind C-'\' select-layout "even-horizontal"
bind C-r rotate-window
# Can't get this fucker to cooperate.
# May however be terminal related issue.
# unbind C-BSpace
bind C-BSpace select-layout "even-vertical"
###--- Smart pane switching with awareness of Vim splits ---###
# 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'
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'"
# bind-key -n 'C-Space' if-shell "$is_vim" 'send-keys C-Space' 'select-pane -t:.+'
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
# bind-key -T copy-mode-vi 'C-Space' select-pane -t:.+
# Ensure window selection also works with keyboaord
bind-key -n KP0 select-window -t :0
bind-key -n KP1 select-window -t :1
bind-key -n KP2 select-window -t :2
bind-key -n KP3 select-window -t :3
bind-key -n KP4 select-window -t :4
bind-key -n KP5 select-window -t :5
bind-key -n KP6 select-window -t :6
bind-key -n KP7 select-window -t :7
bind-key -n KP8 select-window -t :8
bind-key -n KP9 select-window -t :9
# Keybinds to join panes
bind-key S choose-window "join-pane -v -s "%%""
bind-key V choose-window "join-pane -h -s "%%""