-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtmux.conf
184 lines (152 loc) · 7.67 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
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
# See:
# https://medium.com/free-code-camp/tmux-in-practice-series-of-posts-ae34f16cfab0
# among other links in this document
# Dont use C-w because that conflicts with my vim bindings
# remap prefix from 'C-b' to 'C-w'
#unbind C-w
#unbind C-b
#set-option -g prefix C-w
#bind-key C-w send-prefix
# split panes using | and -
# (to denote vertical and horizontal respectively)
bind | split-window -h
bind - split-window -v
unbind '"'
unbind %
# split the largest direction automagically
bind -n M-Enter if-shell "[ $(($(tmux display -p '8*#{pane_width}-20*#{pane_height}'))) -lt 0 ]" "splitw -v -c '#{pane_current_path}'" "splitw -h -c '#{pane_current_path}' "
# Set a Ctrl-b shortcut for reloading your tmux config
bind r source-file ~/.tmux.conf
## Automatically set window title
set-window-option -g automatic-rename on
set-option -g set-titles on
setw -g monitor-activity on
# Rename your terminals
#set -g set-titles on
#set -g set-titles-string '#(whoami)::#h::#(curl ipecho.net/plain;echo)'
# Set vi bindings
# Copy mode: CTRL + b [
set-window-option -g mode-keys vi
set -g history-limit 10000
# Trigger copy mode with e (for edit) instead of CTRL-B [
bind e copy-mode
# This makes copy mode act like vim's visual mode for convenience
# https://github.com/tmux/tmux/issues/754
#bind-key -T copy-mode-vi v send-keys -X begin-selection
#bind-key -T copy-mode-vi y send-keys -X copy-selection-and-cancel
unbind-key -T copy-mode-vi Space ; bind-key -T copy-mode-vi v send-keys -X begin-selection
unbind-key -T copy-mode-vi Enter ; bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "reattach-to-user-namespace pbcopy"
unbind-key -T copy-mode-vi C-v ; bind-key -T copy-mode-vi C-v send-keys -X rectangle-toggle
unbind-key -T copy-mode-vi [ ; bind-key -T copy-mode-vi [ send-keys -X begin-selection
unbind-key -T copy-mode-vi ] ; bind-key -T copy-mode-vi ] send-keys -X copy-selection
# Make sure tmux doesn't snarf the escape key which cause problems for vim
set -sg escape-time 0
# I don't use vim splits a lot so in the end this is not useful, but kept in
# case I move to wanting this type of movement later
# Remap window navigation to vim
#unbind-key j
#bind-key j select-pane -D
#unbind-key k
#bind-key k select-pane -U
#unbind-key h
#bind-key h select-pane -L
#unbind-key l
#bind-key l select-pane -R
# 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'"
# https://thoughtbot.com/blog/seamlessly-navigate-vim-and-tmux-splits
# smart pane switching with awareness of vim splits
#bind -n C-h run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-h) || tmux select-pane -L"
#bind -n C-h run "(tmux display-message -p '#{pane_current_command}' | grep -i vim && tmux send-keys C-h) || tmux select-pane -L"
#bind -n C-j run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-j) || tmux select-pane -D"
#bind -n C-k run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-k) || tmux select-pane -U"
#bind -n C-l run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-l) || tmux select-pane -R"
#bind -n C-\ run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys 'C-\\') || tmux 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
# Fast moving between panes that is vimlike
bind-key -n 'C-h' select-pane -L
bind-key -n 'C-j' select-pane -D
bind-key -n 'C-k' select-pane -U
bind-key -n 'C-l' select-pane -R
bind-key -n 'C-\' select-pane -l
# Resize windows with capitals
bind-key J resize-pane -D 5
bind-key K resize-pane -U 5
bind-key H resize-pane -L 5
bind-key L resize-pane -R 5
## Use Alt-vim keys without prefix key to switch panes
# Does this work? Probably should be removed
bind -n M-h select-pane -L
bind -n M-j select-pane -D
bind -n M-k select-pane -U
bind -n M-l select-pane -R
# Swap panes
# See
# https://www.reddit.com/r/tmux/comments/j7fcr7/tiling_in_tmux_as_in_bspwm
bind -n M-Space run-shell 'bash -c "tmux swap-pane -t \$(tmux list-panes -F \"##P 8*##{pane_width}*20*##{pane_height}\" | while read l; do t=( \$l );echo \"\${t[0]} \$((\${t[1]}))\";done | sort -k 2 -r -g | cut -d\" \" -f1 | head -n 1)"'
## THEME
#git clone https://github.com/jimeh/tmux-themepack.git ~/.tmux-themepack
#git clone https://github.com/seebi/tmux-colors-solarized.git .tmux-theme-solarized
#source-file "${HOME}/.tmux-themepack/powerline/default/yellow.tmuxtheme"
#source-file "${HOME}/.tmux-themepack/powerline/default/purple.tmuxtheme"
#source-file "${HOME}/.tmux-themepack/powerline/block/cyan.tmuxtheme"
source-file "${HOME}/.tmux-themepack/powerline/double/cyan.tmuxtheme"
#source-file "${HOME}/.tmux-theme-solarized/tmuxcolors-256.conf"
#set -g status-bg black
#set -g status-fg white
##set -g window-status-current-bg white
##set -g window-status-current-fg black
##set -g window-status-current-attr bold
#set -g status-interval 60
#set -g status-left-length 30
#set -g status-left '#[fg=green](#S) #(whoami) '
#set -g status-right '#[fg=yellow]#(hostname)#[default] #[fg=white]%H:%M#[default]'
##set -g status-right '#[fg=yellow]#(cut -d " " -f 1-3 /proc/loadavg)#[default] #[fg=white]%H:%M#[default]'
#===========================================================================
# Mouse stuff
#===========================================================================
# Enable mouse mode (tmux 2.1 and above)
set -g mouse on
# See: https://medium.com/free-code-camp/tmux-in-practice-scrollback-buffer-47d5ffa71c93
# When scrolling with mouse wheel, reduce number of scrolled rows per tick to "2" (default is 5)
bind -T copy-mode-vi WheelUpPane select-pane \; send-keys -X -N 2 scroll-up
bind -T copy-mode-vi WheelDownPane select-pane \; send-keys -X -N 2 scroll-down
# Do not copy selection and cancel copy mode on drag end event
# Prefer iTerm style selection: select, then mouse click to copy to buffer
unbind -T copy-mode-vi MouseDragEnd1Pane
bind -T copy-mode-vi MouseDown1Pane select-pane \;\
send-keys -X copy-pipe "pbcopy" \;\
send-keys -X clear-selection
# Double LMB Select & Copy (Word)
# For tmux 2.8 ?
# https://stackoverflow.com/questions/31404140/can-i-use-double-click-to-select-and-copy-in-tmux/46638561
# pbcopy => mac, xclip => xwindows
bind-key -n DoubleClick1Pane \
select-pane \; \
copy-mode -M \; \
send-keys -X select-word \; \
run-shell "sleep .5s" \; \
send-keys -X copy-pipe-and-cancel "pbcopy"
# send-keys -X copy-pipe-and-cancel "xclip -in -sel primary"
bind-key -n DoubleClick1Pane \
select-pane \; \
copy-mode -M \; \
send-keys -X select-word \; \
run-shell "sleep .5s" \; \
send-keys -X copy-pipe-and-cancel "pbcopy"
# send-keys -X copy-pipe-and-cancel "xclip -in -sel primary"