forked from thoughtbot/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtmux.conf
124 lines (102 loc) · 4.19 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
# Terminal type configuration
set -g default-terminal 'tmux-256color'
set -ga terminal-overrides ",xterm-256color:Tc"
# Pane splitting and resizing
unbind '"'
unbind '%'
bind-key '\' split-window -h -c "#{pane_current_path}"
bind-key '-' split-window -v -c "#{pane_current_path}"
bind -r H resize-pane -L 5
bind -r J resize-pane -D 5
bind -r K resize-pane -U 5
bind -r L resize-pane -R 5
bind -r Space next-layout
# Vim Style Pane Navigation
is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
| grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"
is_fzf="ps -o state= -o comm= -t '#{pane_tty}' \
| grep -iqE '^[^TXZ ]+ +(\\S+\\/)?fzf$'"
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 || $is_fzf" "send-keys C-j" "select-pane -D"
bind-key -n 'C-k' if-shell "$is_vim || $is_fzf" "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
# Window movement
bind -r "<" swap-window -t -1
bind -r ">" swap-window -t +1
# Window navigation
bind -r [ previous-window
bind -r ] next-window
# Vi bindings for everything
set -g status-keys vi
set -g mode-keys vi
# remap prefix from 'C-b' to 'C-s'
unbind C-b
set -g prefix C-s
bind C-s run 'true' # Use prefix as toggle
# start tab numbering on 1
set -g base-index 1
# start pane numbering on 1
setw -g pane-base-index 1
# Automatically re-number windows after one of them is closed
set -g renumber-windows on
# Increase the scrollback history limit to make Tmux panes remember more lines:
set -g history-limit 10000
set -g mouse on
# Easy reloading of tmux config
bind r run -b ' \
tmux source-file ~/.tmux.conf > /dev/null; \
tmux display-message "Sourced .tmux.conf!"'
# Copy and paste
# ---------------------------------------------------------------
# Workaround to allow accessing OSX pasteboard
set-option -g default-command "reattach-to-user-namespace -l $SHELL"
bind p run "reattach-to-user-namespace pbpaste | tmux load-buffer -; tmux paste-buffer"
bind y copy-mode
bind -T copy-mode-vi 'v' send -X begin-selection
bind -T copy-mode-vi 'y' send -X copy-pipe-and-cancel "tmux save-buffer - | reattach-to-user-namespace pbcopy"
# Status bar
# ---------------------------------------------------------------
# Update the status bar every few seconds
set -g status-interval 5
# <host> .... <windows> .... <info>
set -g status-left ' #h '
set -g status-left-length 30
set -g window-status-format ' #{?window_zoomed_flag,* ,}#I:#W '
set -g window-status-current-format ' #{?window_zoomed_flag,* ,}#I:#W '
set -g status-right '%m/%d | %H:%M '
set -g status-justify centre
set -g status-right '#{prefix_highlight} | #{battery_icon} #{battery_percentage} | %m/%d | %H:%M '
# Plugin Settings
# ---------------------------------------------------------------
set -g @batt_discharging_icon '-'
set -g @batt_full_charge_icon '-'
set -g @batt_high_charge_icon '-'
set -g @batt_medium_charge_icon '-'
set -g @batt_low_charge_icon '-'
set -g @batt_charged_icon ' '
set -g @batt_charging_icon '+'
set -g @resurrect-dir "~/.tmux/tmux/resurrect"
set -g @resurrect-save 'S'
set -g @resurrect-restore 'R'
set -g @resurrect-capture-pane-contents 'off'
set -g @resurrect-save-shell-history 'off'
# Tmux plugins
# ---------------------------------------------------------------
# List of plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'tmux-plugins/tmux-battery'
set -g @plugin 'tmux-plugins/tmux-prefix-highlight'
set -g @plugin 'tmux-plugins/tmux-resurrect'
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'