-
Notifications
You must be signed in to change notification settings - Fork 2
/
tmux.conf
90 lines (70 loc) · 3.37 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
set -g default-terminal "xterm-256color"
set -sa terminal-overrides ",xterm*:Tc"
set-option -g xterm-keys on
set -g prefix C-s
bind-key C-s send-prefix
set -s escape-time 0
bind r source-file ~/.tmux.conf \; display "Reloaded ~/.tmux.conf"
# sessions
bind n new-session
# windows
set -g base-index 1
setw -g automatic-rename on
set -g renumber-windows on
bind-key Space select-layout even-vertical
bind-key C-s last-window
bind , command-prompt "rename-window '%%'"
bind-key X kill-window
bind c new-window -c "#{pane_current_path}"
if "[[ `tmux -V` == *1.9* ]]" 'unbind c; bind c new-window -c "#{pane_current_path}"'
# move windows left/right
bind-key h swap-window -d -t -1
bind-key l swap-window -d -t +1
# panes
bind S split-window -v -c "#{pane_current_path}"
bind s split-window -v -p 33 -c "#{pane_current_path}"
bind v split-window -h -c "#{pane_current_path}"
bind V split-window -h -p 33 -c "#{pane_current_path}"
bind C-z resize-pane -Z
bind H swap-pane -U
bind L swap-pane -D
bind-key e setw synchronize-panes
set -g history-limit 100000
# pane switching with awareness of vim splits
# 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 -n C-h run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)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 '(^|\/)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 '(^|\/)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 '(^|\/)vim(diff)?$|emacs.*$' && tmux send-keys C-l) || tmux select-pane -R"
# pane resizing
bind -r C-h resize-pane -L 5
bind -r C-j resize-pane -D 5
bind -r C-k resize-pane -U 5
bind -r C-l resize-pane -R 5
bind C-z resize-pane -Z
# copy mode
setw -g mode-keys vi
bind ` copy-mode
unbind [
unbind p
bind p paste-buffer
bind -Tcopy-mode-vi v send -X begin-selection
bind -Tcopy-mode-vi y send -X copy-selection
bind -Tcopy-mode-vi Escape send -X cancel
# colors
set -g status-style "bg=black, fg=white"
if "test -f ~/.tmuxcolors.conf" "source ~/.tmuxcolors.conf"
# open pane in vim
bind-key / capture-pane -S - -J \; new-window 'vim -c ":read !tmux save-buffer - ; tmux delete-buffer;" -c ":normal G" -c ":set buftype=nofile" -c ":silent! %s/\s\+$//"'
# open pane in vim, last command only, non-breaking-space u00A0, expected to mark each prompt, should be in bash's $PS1
bind-key / capture-pane -S - -J \; new-window 'vim -c ":read !tmux save-buffer - ; tmux delete-buffer;" -c ":set buftype=nofile" -c ":silent! %s/\s\+$//" -c ":silent! 1,?\%u00a0.?-1 delete"'
bind-key ? capture-pane -S - -J \; new-window 'vim -c ":read !tmux save-buffer - ; tmux delete-buffer;" -c ":set buftype=nofile" -c ":silent! %s/\s\+$//"'
# clear history
bind k send-keys -R \; clear-history
# status line
set -g status-right " \"#{=21:pane_title}\" %b %d %H:%M"
# local conf
if "test -f ~/.tmuxlocal.conf" "source ~/.tmuxlocal.conf"
# search for non-breaking-space u00A0, expected to mark each prompt, should be in bash's $PS1
bind-key b copy-mode\; send-keys -X start-of-line\; send-keys -X search-backward " [a-zA-Z\.]"