-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtmux.conf
140 lines (107 loc) · 4.22 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
set -g default-terminal "tmux-256color"
set -ga terminal-overrides ",xterm-256color:Tc"
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin "jlipps/tmux-safekill"
set -g default-command "${SHELL}"
# Increase scrollback buffer
set -g history-limit 500000
set -s escape-time 0
set-option -s set-clipboard off
# Reorganize window indexes automatically
set-option -g renumber-windows on
# Tmux colorscheme
source-file ~/dotfiles/tmux.colorscheme.conf
# TMUX auto renaming
setw -g automatic-rename off
# Kill pane without confirmation
bind-key x kill-pane
# Force a reload of the config file
unbind r
bind r source-file ~/.tmux.conf \; display "TMUX conf reloaded!"
# Enable mouse mode
set -g mouse on
# Use prefix C-l to clear the visible scrollback lines
bind-key C-l send-keys 'C-l'
# Use prefix C-k to clear the scrolled off (hidden) buffer lines
bind-key C-k clear-history
# C-z zoom current pane
unbind C-z
bind -n C-z resize-pane -Z
# tmux vi
setw -g mouse on
setw -g mode-keys vi
# Use v to trigger selection
bind-key -T copy-mode-vi v send-keys -X begin-selection
bind-key -T copy-mode-vi C-v send-keys -X rectangle-toggle \; send -X begin-selection
# Use y to yank current selection
bind-key -T copy-mode-vi y send-keys -X copy-selection-and-cancel
# Update default binding of `Enter` to also use copy-pipe
unbind -T copy-mode-vi Enter
# For windows wsl
if-shell 'uname -a | grep -qi microsoft' \
"bind -T copy-mode-vi y send -X copy-pipe 'tmux show-buffer | clip.exe'" \
"bind -T copy-mode-vi y send -X copy-pipe 'xclip -sel clip -i'"
unbind C-[
bind C-[ copy-mode
# Screen like binding
unbind C-b
set -g prefix C-a
bind a send-prefix
bind-key S choose-session
# Create splits and vertical splits
bind-key v split-window -h -l 50% -c "#{pane_current_path}"
bind-key ^V split-window -h -l 50% -c "#{pane_current_path}"
bind-key s split-window -l 50% -c "#{pane_current_path}"
bind-key ^S split-window -l 50% -c "#{pane_current_path}"
# Move window indexes
bind-key C-S-Left swap-window -t -1\; select-window -t -1
bind-key C-S-Right swap-window -t +1\; select-window -t +1
# Use prefix C-k to clear the scrolled off (hidden) buffer lines
bind-key C-k clear-history \; display "Pane history cleared!"
# Clear pane
bind-key C-l send-keys C-l
# Break pane into a tmux window
bind b break-pane -d
# Join pane from another tmux tab (joins the last selected pane from that window)
bind-key j command-prompt -p "join pane from: " "join-pane -h -s '%%'"
# Tmux pane swap
bind -n C-M-Left swap-pane -s "{left-of}"
bind -n C-M-Right swap-pane -s "{right-of}"
bind -n C-M-Up swap-pane -s "{up-of}"
bind -n C-M-Down swap-pane -s "{down-of}"
#
# # Tmux resize
bind -n S-Left resize-pane -L 2
bind -n S-Right resize-pane -R 2
bind -n S-Down resize-pane -D 1
bind -n S-Up resize-pane -U 1
#
bind -n C-Left resize-pane -L 10
bind -n C-Right resize-pane -R 10
bind -n C-Down resize-pane -D 5
bind -n C-Up resize-pane -U 5
# C-z zoom current pane
unbind C-z
bind -n C-z resize-pane -Z
# 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 '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 -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
set -g focus-events on
if "test ! -d ~/.tmux/plugins/tpm" \
"run 'git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm && ~/.tmux/plugins/tpm/bin/install_plugins'"
run -b '~/.tmux/plugins/tpm/tpm'