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
|
# Special thanks to Nicholas Marriott.
# Enable RGB color if running in xterm
set-option -sa terminal-overrides ",xterm*:Tc"
# Change the default $TERM to xterm-256color
# Necessary because vim ctrl arrows must be defined through TERM
set -g default-terminal "xterm-256color"
set-window-option -g xterm-keys on
# No bells at all
set -g bell-action none
# Keep windows around after they exit
set -g remain-on-exit off
# More history lines
set -g history-limit 16384
# Base window is Numero Uno
set -g base-index 1
set-window-option -g pane-base-index 1
# Set vi mode when copying
set-window-option -g mode-keys vi
# compatibility with vim for focus based events
set -g focus-events on
set -g mouse
# KEYBINDINGS
set-option -g prefix 'C-_'
bind-key 'C-_' send-prefix
# Reload config file
bind r source-file ~/.config/tmux/tmux.conf \; display "Reloaded ~/.tmux.conf"
# Clipboard
bind -T copy-mode-vi v send-keys -X begin-selection
bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "oclipp"
# Unbind ESC
set -sg escape-time 0
# Toggle status bar
bind t set-option status
# Toggle monitoring window activity
bind m set monitor-activity\; display 'monitor-activity #{?monitor-activity,on,off}'
bind M run-shell "tmux set monitor-silence #{?monitor-silence,0,10}"\; display "monitor-silence #{?monitor-silence,on,off}"
# Toggle synchronized panes (sending keys to every pane)
bind y set synchronize-panes\; display 'synchronize-panes #{?synchronize-panes,on,off}'
# Paste from tmux buffer
bind p paste-buffer
# Kill all windows
bind x confirm -p "Kill Pane?" kill-pane
bind X confirm -p "Kill Window?" kill-window
bind M-x confirm -p "Kill Session?" kill-session
bind M-X confirm -p "Kill Server?" kill-server
# Restart pane
bind C-r run -C "respawn-pane -k; send-keys !! 'C-j'"
bind C-R respawn-pane -k
# Splitting
bind v split-window -h -c "#{pane_current_path}"
bind s split-window -v -c "#{pane_current_path}"
# Swapping left and right a la vim
bind -r H swap-pane -U
bind -r L swap-pane -D
## Resizing panes
bind -n M-H resize-pane -L 5
bind -n M-J resize-pane -D 5
bind -n M-K resize-pane -U 5
bind -n M-L resize-pane -R 5
# Join and break windows
bind j command-prompt -1p "Take window:" "join-pane -s %%"
bind J command-prompt -1p "Send to window:" "join-pane -t \:%% ; select-window -l"
# Break pane without losing focus
bind b break-pane -t :
# Reset length and shit
bind-key z resize-pane -Z
bind-key h select-pane -L
bind-key j select-pane -D
bind-key k select-pane -U
bind-key l select-pane -R
# Pane navigating with h|j|k|l a la vim
# 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|l?n?vim?x?|fzf)(diff)?$'"
bind-key -n 'M-h' if-shell "$is_vim" 'send-keys M-h' 'select-pane -L'
bind-key -n 'M-j' if-shell "$is_vim" 'send-keys M-j' 'select-pane -D'
bind-key -n 'M-k' if-shell "$is_vim" 'send-keys M-k' 'select-pane -U'
bind-key -n 'M-l' if-shell "$is_vim" 'send-keys M-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 -T copy-mode-vi 'M-h' select-pane -L
bind -T copy-mode-vi 'M-j' select-pane -D
bind -T copy-mode-vi 'M-k' select-pane -U
bind -T copy-mode-vi 'M-l' select-pane -R
bind -T copy-mode-vi 'M-\' select-pane -l
bind -n M-u previous-window
bind -n M-i next-window
bind -n M-O last-window
bind -n M-U switch-client -p
bind -n M-I switch-client -n
bind -n M-O switch-client -l
# Renaming
bind n command-prompt "rename-window '%%'"
bind N command-prompt "rename-session '%%'"
# Starting new windows
bind w new-window -c "#{pane_current_path}"
bind W new-session -c "$HOME"
# Show tree
bind S choose-tree -Z
# Menu for mounting and ejecting devices.
bind E display-menu -T "#[align=centre]#I:#W" -x W -y W '' Mount 0 "display-popup -E 'amount'"
bind-key -n M-F run-shell "tmux neww tmux-sessionizer"
# Theme
#+---------+
#+ Options +
#+---------+
set -g status-interval 1
set -g status on
#+--------+
#+ Status +
#+--------+
#+--- Layout ---+
set -g set-titles-string "[#S: #W] #T"
set -g set-titles on
set -g status-position bottom
set -g window-status-current-style "underscore"
set -g status-justify left
set -g status-left-length 16
set -g status-left "#[fg=black,bg=blue,bold] #S #[fg=blue,bg=black,nobold,noitalics,nounderscore]"
set -g status-right "#[fg=brightblack,bg=black,nobold,noitalics,nounderscore]#[fg=white,bg=brightblack] %H:%M #[fg=cyan,bg=brightblack,nobold,noitalics,nounderscore]#[fg=black,bg=cyan,bold] #{user}@#H "
#+--- Colors ---+
set -g status-style bg=black,fg=white
#+-------+
#+ Panes +
#+-------+
set -g pane-border-style bg=default,fg=brightblack
set -g pane-active-border-style bg=default,fg=blue
set -g display-panes-colour black
set -g display-panes-active-colour brightblack
#+------------+
#+ Clock Mode +
#+------------+
setw -g clock-mode-colour cyan
#+----------+
#+ Messages +
#+---------+
set -g message-style bg=brightblack,fg=cyan
set -g message-command-style bg=brightblack,fg=cyan
#+--- Windows ---+
set -g window-status-format "#[fg=black,bg=brightblack,nobold,noitalics,nounderscore] #[fg=white,bg=brightblack]#I #[fg=white,bg=brightblack,nobold,noitalics,nounderscore] #[fg=white,bg=brightblack]#W #F #[fg=brightblack,bg=black,nobold,noitalics,nounderscore]"
set -g window-status-current-format "#[fg=black,bg=cyan,nobold,noitalics,nounderscore] #[fg=black,bg=cyan]#I #[fg=black,bg=cyan,nobold,noitalics,nounderscore] #[fg=black,bg=cyan]#W #F #[fg=cyan,bg=black,nobold,noitalics,nounderscore]"
set -g window-status-separator ""
|