forked from kzwkt/dotfiles-1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dot_tmux.conf
199 lines (178 loc) · 14.9 KB
/
dot_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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
# Please do not modify this file if you want to stay updated with our Github commits
# Instead, create a new file and place it in your ~/.tmux.conf.local instead that will override this file
# GENERAL SETTINGS START HERE {{{
set -g default-terminal "tmux-256color" # 256 color
set -sg escape-time 0 # Time for tmux to wait for key sequence
set -g history-limit 50000 # Maximum number of lines held in window history
set -s buffer-limit 20 # Number of buffers, older than limit buffer will be removed
set -g display-time 1500 # Time for which status line messages and indicators are displayed in miliseconds, 0 means diplay until a key is pressed
setw -g remain-on-exit off # Destroy window when program exits
set -g repeat-time 500 # Typing command without pressing prefix key again in the specified time in miliseconds
setw -g automatic-rename on # Automatic window renaming
setw -g automatic-rename-format '#{pane_current_command}' # Format of automatic window renaming
setw -g allow-rename off # Allow programs to change the window name
setw -g xterm-keys on # Xterm style function key sequences
set -g mouse on # Enable mouse support
set -g status-keys vi # Use vi style keybindings in command prompt
setw -g mode-keys vi # Use vi style keybindings in copy mode
set -g base-index 1 # Starting index for new window
set -g pane-base-index 1 # Starting index for new pane
setw -g aggressive-resize on # Fix from a smaller client issue
# GENERAL SETTINGS END HERE
# }}}
# KEYBINDING SETTINGS START HERE {{{
# Unbind the default key bindings
unbind C-b # send-prefix
unbind '"' # split-window
unbind '$' # command-prompt -I'#S' \"rename-session -- '%%'\"
unbind % # split-window -h
unbind & # confirm-before -p\"kill-window #W? (y/n)\" kill-window
unbind , # command-prompt -I'#W' \"rename-window -- '%%'\"
unbind - # delete-buffer
unbind . # command-prompt \"move-window -t '%%'\"
unbind \; # last-pane
unbind = # choose-buffer -Z
unbind E # select-layout -E
unbind L # switch-client -l
unbind M # select-pane -M
unbind [ # copy-mode
unbind ] # paste-buffer
unbind f # command-prompt \"find-window -Z -- '%%'\"
unbind l # last-window
unbind n # next-window
unbind o # select-pane -t:.+
unbind p # previous-window
unbind r # refresh-client
unbind s # choose-tree -Zs
unbind w # choose-tree -Zw
unbind x # confirm-before -p\"kill-pane #P? (y/n)\" kill-pane"
unbind '{' # swap-pane -U
unbind '}' # swap-pane -D
unbind M-n # next-window -a
unbind M-p # previous-window -a
unbind M-Up # resize-pane -U 5
unbind M-Down # resize-pane -D 5
unbind M-Left # resize-pane -L 5
unbind M-Right # resize-pane -R 5
unbind C-Up # resize-pane -U
unbind C-Down # resize-pane -D
unbind C-Left # resize-pane -L
unbind C-Right # resize-pane -R
# Now set our custom key bindings
set -g prefix M-a # Prefix key is now Alt+a
bind -n M-z send-prefix # Prefix key for client Tmux is Alt+z
# After pressing prefix key, you can continue with keybindings below to do stuffs
bind M-r source-file $HOME/.tmux.conf \; display 'Tmux Reloaded' # Alt+r to reload configuration
bind f choose-tree # f to find session, window, or pane from a list
bind M-s split-window -h # Alt+s to make new split window
bind M-v split-window -v # Alt+v to make new vertical split window
bind r command-prompt -I'#W' "rename-window -- '%%'" # r to rename current window
bind R command-prompt -I'#S' "rename-session -- '%%'" # R to rename current session
# Alt+e to edit tmux.conf.local file
bind M-e new-window "sh -c '\${EDITOR:-vim} ~/.tmux.conf.local && tmux source ~/.tmux.conf && tmux display \"Tmux Reloaded\"'"
# Moving between panes
bind -r h select-pane -L # h to move left
bind -r j select-pane -D # j to move down
bind -r k select-pane -U # k to move up
bind -r l select-pane -R # l to move right
bind -r > swap-pane -D # > to swap to the next pane
bind -r < swap-pane -U # < to swap to the previous pane
# Resizing panes
bind -r H resize-pane -L 2 # H to resize to the left
bind -r J resize-pane -D 2 # J to resize downwards
bind -r K resize-pane -U 2 # K to resize upwards
bind -r L resize-pane -R 2 # L to resize to the right
# Moving between windows
bind -r M-n next-window # Alt+n to move next window
bind -r M-p previous-window # Alt+p to move previous window
bind -r Tab next-window # Tab to move next window (in case your window manager use M-l already)
bind S choose-window "join-pane -v -t "%%"" # S to join pane to selected window in horizontal split
bind V choose-window "join-pane -h -t "%%"" # V to join pane to selected window in vertical split
# Closing everything
bind x kill-pane # x to close pane
bind X kill-window # X to close window
bind M-x confirm-before -p"kill other windows? (y/n)" "kill-window -a" # Alt+x to close other windows
# Copy and paste to bufer
bind a copy-mode # a to trigger copy mode
bind p paste-buffer # p to paste from top buffer
bind P choose-buffer # Alt+p to choose buffer to paste
# Copy mode keybindings
bind -T copy-mode-vi v send -X begin-selection # v in copy mode to begin selection
bind -T copy-mode-vi M-v send -X rectangle-toggle # Alt+v in copy mode to toggle rectangle select
bind -T copy-mode-vi y send -X copy-selection-and-cancel # y in copy mode to yank selection
bind -T copy-mode-vi Y send -X copy-line # Y in copy mode to yank a line
bind -T copy-mode-vi Escape send -X cancel # Esc in copy mode to exit copy mode
# macOS clipboard support with pbcopy
if -b "command -v reattach-to-user-namespace > /dev/null 2>&1" "\
run 'tmux set -g default-command \"exec $(tmux show -gv default-shell) 2>/dev/null & reattach-to-user-namespace -l $(tmux show -gv default-shell)\"'"
if -b "command -v pbcopy > /dev/null 2>&1" " \
bind -T copy-mode-vi y send -X copy-pipe-and-cancel 'reattach-to-user-namespace pbcopy'; \
bind -T copy-mode-vi Y send -X copy-line \\; run 'tmux save-buffer - | reattach-to-user-namespace pbcopy'; \
bind -T copy-mode-vi D send -X copy-end-of-line \\; run 'tmux save-buffer - | reattach-to-user-namespace pbcopy'; \
bind -T copy-mode-vi MouseDragEnd1Pane send -X copy-pipe-and-cancel 'reattach-to-user-namespace pbcopy'"
# Linux clipboard support with xsel or xclip
if -b "command -v xsel > /dev/null 2>&1" " \
bind -T copy-mode-vi y send -X copy-pipe-and-cancel 'xsel -i -b'; \
bind -T copy-mode-vi Y send -X copy-line \\; run 'tmux save-buffer - | xsel -i -b'; \
bind -T copy-mode-vi D send -X copy-end-of-line \\; run 'tmux save-buffer - | xsel -i -b'; \
bind -T copy-mode-vi MouseDragEnd1Pane send -X copy-pipe-and-cancel 'xsel -i -b'"
if -b "! command -v xsel > /dev/null 2>&1 && command -v xclip > /dev/null 2>&1" " \
bind -T copy-mode-vi y send -X copy-pipe-and-cancel 'xclip -i -selection clipboard >/dev/null 2>&1'; \
bind -T copy-mode-vi Y send -X copy-line \\; run 'tmux save-buffer - | xclip -i -selection clipboard >/dev/null 2>&1'; \
bind -T copy-mode-vi D send -X copy-end-of-line \\; run 'tmux save-buffer - | xclip -i -selection clipboard >/dev/null 2>&1'; \
bind -T copy-mode-vi MouseDragEnd1Pane send -X copy-pipe-and-cancel 'xclip -i -selection clipboard >/dev/null 2>&1'"
# KEYBINDING SETTINGS END HERE
# }}}
# APPEARANCE SETTINGS START HERE {{{
# Default value for statusline format, set it up in custom config file if you want
POWERLINE_SEPARATOR_LEFT=""
POWERLINE_SEPARATOR_RIGHT=""
POWERLINE_SEPARATOR_LEFT_THIN=""
POWERLINE_SEPARATOR_RIGHT_THIN=""
POWERLINE_SESSION_ICON=" "
POWERLINE_USER_ICON=" "
POWERLINE_WINDOW_ICON=""
POWERLINE_WINDOW_ACTIVE_ICON=" "
POWERLINE_COMMAND_ICON=" "
POWERLINE_CLOCK_ICON=" "
POWERLINE_LOGO=" "
BLACK="colour235"
RED="colour9"
GREEN="colour2"
YELLOW="colour11"
BLUE="colour12"
PURPLE="colour5"
TEAL="colour6"
WHITE="colour15"
set -g set-titles on # Set terminal title
set -g set-titles-string "❐ Tmux #{version} [#S] #I ➤ #W" # Terminal title bar format
setw -g mode-style "fg=$WHITE,bg=$BLUE" # Window mode style
set -g message-style "fg=$WHITE,bold,bg=$GREEN" # Status line message style
set -g message-command-style "fg=$BLACK,bold,bg=$BLUE" # Status line message command style
set -g status on # Show or hide status line
set -g status-interval 1 # Update status line every interval second
set -g status-justify left # Set the position of the window list component of status line
set -g status-position bottom # Set the position of status line
setw -g clock-mode-colour "$YELLOW" # Set clock color
setw -g clock-mode-style 12 # Set clock hour format
setw -g window-status-activity-style "fg=$RED" # Window with activity alert style
setw -g window-status-separator "" # Set the separator drawn between windows in status line
set -g status-left-length 100 # Set the maximum length of left status line
set -g status-right-length 100 # Set the maximum length of right status line
set -g status-style "bg=$BLACK" # Status line style
setw -g pane-border-status off # Pane border status line
setw -g pane-border-style "fg=$BLUE" # Pane border style
setw -g pane-active-border-style "fg=$RED" # Active pane border style
# Move status line to top if tmux is nested inside another tmux so they don't colide
if -b "test -n '$SSH_CLIENT'" "set -g status-position top"
# Left status line configurations
set -g status-left "#[fg=$BLACK,bold,bg=$BLUE] $POWERLINE_SESSION_ICON#S #[fg=$BLUE,bg=$YELLOW]$POWERLINE_SEPARATOR_RIGHT#[fg=$BLACK,bold] $POWERLINE_USER_ICON#(whoami) #[fg=$YELLOW,bg=$GREEN]$POWERLINE_SEPARATOR_RIGHT#[fg=$BLACK,bold]$POWERLINE_LOGO#[fg=$GREEN,bg=$BLACK]$POWERLINE_SEPARATOR_RIGHT"
# Right status line configurations
set -g status-right "#[fg=$BLUE,bg=$BLACK]$POWERLINE_SEPARATOR_LEFT#[fg=$BLACK,bold,bg=$BLUE] #T$POWERLINE_COMMAND_ICON #[fg=$PURPLE,bg=$BLUE]$POWERLINE_SEPARATOR_LEFT#[fg=$BLACK,bold,bg=$PURPLE] %a,%d %b %y | %I:%M %p$POWERLINE_CLOCK_ICON "
# Window status line configurations
setw -g window-status-current-format "#[fg=$BLUE,bg=$BLACK] #I #[fg=$BLACK,bold,bg=$BLUE]$POWERLINE_SEPARATOR_RIGHT $POWERLINE_WINDOW_ACTIVE_ICON#W #[fg=$BLUE,bg=$BLACK]$POWERLINE_SEPARATOR_RIGHT"
setw -g window-status-format "#[fg=$WHITE,bg=$BLACK] #I $POWERLINE_SEPARATOR_RIGHT_THIN $POWERLINE_WINDOW_ICON#W $POWERLINE_SEPARATOR_RIGHT_THIN"
# APPEARANCE SETTINGS END HERE
# }}}
# Use user defined overrides if .tmux.conf.local file is found
if "[-f ~/.tmux.conf.local]" "source ~/.tmux.conf.local"