forked from pvrego/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.tmux.conf
199 lines (164 loc) · 8.47 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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
#set-option -g prefix C-Space # C-SPC as tmux key
set-option -g prefix C-a
bind-key C-s last-window # Go to last window with C-SPC C-s
bind-key C-a last-pane # Go to last pane with C-SPC C-a
#set-option -g prefix C-b
#bind-key C-w last-window # Go to last window with C-b C-w
#bind-key C-b last-pane # Go to last pane with C-b C-b
# enable reattach-to-user-namespace which fixes pasteboard access and launchctl
# inside tmux
#set-option -g default-command "reattach-to-user-namespace -l zsh"
if-shell 'uname | grep -qi Darwin' 'set-option -g default-command "reattach-to-user-namespace -l zsh"'
set -g default-terminal "screen-256color"
setw -g mode-keys vi
set -g history-limit 10000
# vi-like text yanking in copy mode
unbind [
bind Escape copy-mode
unbind p
#bind p paste-buffer
#bind-key -t vi-copy 'v' begin-selection
#bind-key -t vi-copy 'y' copy-selection
bind-key -T copy-mode-vi v send-keys -X begin-selection
#bind-key -T copy-mode-vi y send-keys -X copy-selection
# Copy
if-shell 'uname | grep -qi Linux && which xclip > /dev/null' 'bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "DISPLAY=:0 xclip -i -sel clipboard"'
if-shell 'uname | grep -qi Darwin && which reattach-to-user-namespace > /dev/null' 'bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "reattach-to-user-namespace pbcopy"'
# Paste
if-shell 'uname | grep -qi Linux && which xclip > /dev/null' 'bind p run "DISPLAY=:0 xclip -o | tmux load-buffer - ; tmux paste-buffer"'
if-shell 'uname | grep -qi Darwin && which reattach-to-user-namespace > /dev/null' 'bind p run "reattach-to-user-namespace pbpaste | tmux load-buffer - ; tmux paste-buffer"'
# vi-like movement
#bind-key k select-pane -U
#bind-key j select-pane -D
#bind-key h select-pane -L
#bind-key l select-pane -R
bind -r K resize-pane -U 5
bind -r J resize-pane -D 5
bind -r H resize-pane -L 5
bind -r L resize-pane -R 5
# traditional navigation
bind -r h select-pane -L
bind -r j select-pane -D
bind -r k select-pane -U
bind -r l select-pane -R
# Smart pane switching with awareness of vim splits
#is_vim='echo "#{pane_current_command}" | grep -iqE "(^|\/)g?(view|n?vim?)(diff)?$"'
#bind -n C-h if-shell "$is_vim" "send-keys C-h" "select-pane -L"
#bind -n C-j if-shell "$is_vim" "send-keys C-j" "select-pane -D"
#bind -n C-k if-shell "$is_vim" "send-keys C-k" "select-pane -U"
#bind -n C-l if-shell "$is_vim" "send-keys C-l" "select-pane -R"
#bind -n C-\ if-shell "$is_vim" "send-keys C-\\" "select-pane -l"
#bind h run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-h) || tmux select-pane -L"
#bind j run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-j) || tmux select-pane -D"
#bind k run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-k) || tmux select-pane -U"
#bind l run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-l) || tmux select-pane -R"
bind -n C-h run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)n?vim(diff)?$|emacs.*$' && tmux send-keys C-h) || tmux select-pane -L"
bind -n C-j run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)n?vim(diff)?$|emacs.*$' && tmux send-keys C-j) || tmux select-pane -D"
bind -n C-k run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)n?vim(diff)?$|emacs.*$' && tmux send-keys C-k) || tmux select-pane -U"
bind -n C-l run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)n?vim(diff)?$|emacs.*$' && tmux send-keys C-l) || tmux select-pane -R"
# Copy mode with <C-Space><Space>
bind Space copy-mode
bind C-Space copy-mode
# zoom pane
bind -r z resize-pane -Z
# resize window to smallest client actually viewing it
setw -g aggressive-resize on
# list all clients with <prefix> D and deselect with <enter>
bind R source-file ~/.tmux.conf \; display "Source file reloaded"
set -g base-index 1 # start window numbering at 1
set -g pane-base-index 1 # start pane numbering at 1
set -g renumber-windows on # renumber remaining windows when a window is closed
# mouse behavior (pre 2.1)
#setw -g mode-mouse on
#set -g mouse-select-pane on
#set -g mouse-resize-pane on
#set -g mouse-select-window on
# mouse behavior (2.1+)
set -g mouse on
#setw -g utf8 on
#setw -g status-utf8 on
setw -g automatic-rename on
# Allows us to use C-a a <command> to send commands to a TMUX session inside
# another TMUX session
bind-key a send-prefix
# Color definitions; see list with following script:
# #!/bin/bash
# for i in {0..255} ; do
# printf "\x1b[38;5;${i}mcolour${i}\n"
# done
# Set status bar on bottom for OSX, on top for Linux
set -g status-position bottom
#if-shell 'uname | grep -qi Linux > /dev/null' 'set -g status-position top'
set -g status-interval 5
set -g status-bg default
set -g status-fg cyan
#set -g status-right "#[fg=green]#H"
set -g status-left-length 40
set -g status-left "#[fg=red]#(hostname|sed \"s/\\\\..*$//\") #[fg=green]s:#S #[fg=yellow]w:#I #[fg=cyan]p:#P"
set -g status-right-length 60
#set -g status-right "#[fg=cyan]#(acpi|sed 's/Battery//; s/0://; s/Discharging//; s/Full, //; s/remaining//; s/ , //; s/Charging, /+/; s/ until charged/ /; s/, / /; s/Unknown //; s/ $//;') #[fg=yellow]#(cat /proc/loadavg|awk '{print $1;}') #[fg=green]%d %b %R"
#set -g status-right "#[fg=cyan]#(~/bin/battery) #[fg=yellow]#(cat /proc/loadavg|awk '{print $1;}') #[fg=green]%d %b %R"
#
#set -g status-right "#[fg=cyan]#(~/bin/battery) #[fg=yellow]#(uptime|awk '{print \$NF;}') #[fg=green]%d %b %R"
if-shell 'uname | grep -qi Darwin' "set -g status-right \"#[fg=#81a2be]#(/usr/local/bin/mpc | head -n 1 | sed 's/volume.*$//' | cut -c 1-22) #[fg=cyan]#(~/bin/battery-osx) #(~/bin/mailstatus.sh) #[fg=yellow]#(uptime|sed 's/.* //') #[fg=green]%Y-%m-%d %R\""
if-shell 'uname | grep -qi Linux' "set -g status-right \"#[fg=cyan]#(acpi|sed 's/Battery//; s/0://; s/Discharging//; s/Full, //; s/remaining//; s/ , //; s/Charging, /+/; s/ until charged/ /; s/, / /; s/Unknown //; s/ $//;') #(~/bin/mailstatus.sh) #[fg=yellow]#(cat /proc/loadavg|awk '{print $1;}') #[fg=green]%Y-%m-%d %R\""
set -g status-justify centre
#set -g status-bg default
#set -g status-fg cyan
#set -g status-interval 4
#set -g status-left ''
#set -g status-right ''
#set -g status-left '#[fg=white,bold]#S#[fg=cyan] | #[fg=white,bold]#(echo $USER) '
#set -g status-right '#[fg=white]#H#[fg=cyan] | #[fg=white]#(uname -r)#[default]'
# Timeout for pane-numbering in milliseconds
set-option -g display-panes-time 3000
# Speed up commands
set-option -sg escape-time 0
# Highlight active window
#setw -g window-status-fg cyan
#setw -g window-status-bg default
#setw -g window-status-attr dim
#setw -g window-status-current-fg white
#setw -g window-status-current-bg default
#setw -g window-status-current-attr bright
#setw -g monitor-activity on
# Highlighting the active window in status bar
setw -g window-status-current-bg default
setw -g window-status-current-fg default
setw -g window-status-bg default
setw -g window-status-fg white
setw -g window-status-activity-attr blink
setw -g window-status-activity-bg default
setw -g window-status-activity-fg default
setw -g window-status-bell-attr blink
setw -g window-status-bell-bg default
setw -g window-status-bell-fg default
#setw -g window-status-format '#[fg=default]#[bg=default] #I #[bg=default]#[fg=black,bold] #W '
setw -g window-status-format '#[fg=green]#[bg=default] #I #[bg=default]#[fg=green]#W '
setw -g window-status-current-format '#[fg=red]#[bg=default] #I #[fg=red,bg=default]#W '
#
# Inactive panes
set -g pane-border-fg colour238
#set -g pane-border-bg black
# Active panes
set -g pane-active-border-fg colour247
#set -g pane-active-border-bg yellow
# Status messages
set -g message-fg yellow
set -g message-bg black
set -g message-attr bright
# use urlview to follow URLs
bind-key u capture-pane \; save-buffer /tmp/active_tmux_buffer \; new-window -n urlview '$SHELL -c "urlview < /tmp/active_tmux_buffer && rm /tmp/active_tmux_buffer"'
bind-key o split-window -p 25 '$SHELL -c "offlineimap -qf INBOX"' \; select-pane -l
bind-key O split-window -p 25 '$SHELL -c "offlineimap"' \; select-pane -l
bind-key -r n next-window
bind-key -r N previous-window
# cycle between preset layouts. select specific presets with select-layout <n>
bind-key -r y next-layout
bind-key -r Y previous-layout
bind-key -r r rotate-window
# new windows in same directory
#bind c new-window -c "#{pane_current_path}"
# split panes in same directory
bind-key '"' split-window -c "#{pane_current_path}"
bind-key '%' split-window -h -c "#{pane_current_path}"