-
Notifications
You must be signed in to change notification settings - Fork 2
/
tmux.conf
89 lines (74 loc) · 3.66 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
set -g default-terminal "screen-256color"
# Enable mouse for scrolling and pane resizing in iTerm
set -g mouse on
bind -n WheelUpPane if-shell -F -t = "#{mouse_any_flag}" "send-keys -M" "if -Ft= '#{pane_in_mode}' 'send-keys -M' 'select-pane -t=; copy-mode -e; send-keys -M'"
bind -n WheelDownPane select-pane -t= \; send-keys -M
bind -n C-WheelUpPane select-pane -t= \; copy-mode -e \; send-keys -M
run-shell "tmux setenv -g TMUX_VERSION $(tmux -V | cut -c 6-)"
# tmux 2.4 changed how these bindings work
if-shell -b '[ "$(echo "$TMUX_VERSION < 2.4" | bc)" = 1 ]' \
"bind -t vi-copy C-WheelUpPane halfpage-up; \
bind -t vi-copy C-WheelDownPane halfpage-down; \
bind -t emacs-copy C-WheelUpPane halfpage-up; \
bind -t emacs-copy C-WheelDownPane halfpage-down"
if-shell -b '[ "$(echo "$TMUX_VERSION >= 2.4" | bc)" = 1 ]' \
"bind -T copy-mode-vi C-WheelUpPane send -X halfpage-up; \
bind -T copy-mode-vi C-WheelDownPane send -X halfpage-down"
# from http://robots.thoughtbot.com/tmux-copy-paste-on-os-x-a-better-future
# Setup 'v' to begin selection as in Vim
if-shell -b '[ "$(echo "$TMUX_VERSION < 2.4" | bc)" = 1 ]' \
"bind-key -t vi-copy v begin-selection; \
bind-key -t vi-copy y copy-pipe 'reattach-to-user-namespace pbcopy'; \
unbind -t vi-copy Enter; \
bind-key -t vi-copy Enter copy-pipe 'reattach-to-user-namespace pbcopy'"
if-shell -b '[ "$(echo "$TMUX_VERSION >= 2.4" | bc)" = 1 ]' \
"bind-key -T copy-mode-vi 'v' send -X begin-selection; \
bind-key -T copy-mode-vi 'y' send-keys -X copy-pipe-and-cancel 'reattach-to-user-namespace pbcopy'; \
unbind -T copy-mode-vi Enter; \
bind-key -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel 'reattach-to-user-namespace pbcopy'"
# vim keys, see: https://sanctum.geek.nz/arabesque/vi-mode-in-tmux/
setw -g mode-keys vi
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
bind-key -r C-h select-window -t :-
bind-key -r C-l select-window -t :+
# set window and pane index to 1 (0 by default)
set-option -g base-index 1
setw -g pane-base-index 1
# reload ~/.tmux.conf using PREFIX r
bind r source-file ~/.tmux.conf \; display "Reloaded!"
# ----------------------
# Status Bar
# -----------------------
set-option -g status on # turn the status bar on
set -g status-interval 5 # set update frequencey (default 15 seconds)
set -g status-justify centre # center window list for clarity
# set-option -g status-position top # position the status bar at top of screen
# visual notification of activity in other windows
setw -g monitor-activity on
set -g visual-activity on
# don't automatically rename windows
setw -g automatic-rename on
set -g status-fg white
set -g status-bg colour235
set -g window-status-activity-attr bold
set -g message-fg colour234
set -g message-bg colour143
set -g message-attr bold
set -g status-right ''
set -g status-left '#S'
set -g window-status-format "#[fg=white] #I #W "
set -g window-status-current-format "#[fg=colour234,bg=colour109] #I #W "
# Smart pane switching with awareness of vim splits
# ctrl-h: left pane, ctrl-j: down pane, ctrl-k: up pane, ctrl-l: right pane,
# ctrl-\: previous pane
# 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"
bind-key -n C-\ if-shell "$is_vim" "send-keys C-\\" "select-pane -l"