-
Notifications
You must be signed in to change notification settings - Fork 2
/
tmux.conf
123 lines (92 loc) · 3.55 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
# http://man.openbsd.org/OpenBSD-current/man1/tmux.1
# https://blog.bugsnag.com/tmux-and-vim/
# copy-mode bindings
unbind [
# change copy-mode binding to Esc (toggle)
bind Escape copy-mode
bind-key -T copy-mode-vi Escape send -X cancel
# more like vim (v,V,r and y to yank)
bind-key -T copy-mode-vi 'v' send -X begin-selection
bind-key -T copy-mode-vi 'V' send -X select-line
bind-key -T copy-mode-vi 'r' send -X rectangle-toggle
bind-key -T copy-mode-vi 'y' send -X copy-pipe-and-cancel "pbcopy"
bind-key -T copy-mode-vi Enter send -X copy-pipe-and-cancel "pbcopy"
# default shell is zsh (installed from brew)
set -g default-shell /opt/homebrew/bin/zsh
# window UTF-8 and colors
set -g default-terminal 'screen-256color'
set -ga terminal-overrides ',*256col*:Tc'
# always create new windows with home dir
bind c new-window -c "~/"
# limit history
set -g history-limit 20000
# make delay shorter
set -sg escape-time 0
# commands
bind v command-prompt -p "vi: " "split-window 'exec vi %%'" # vi in split
# kill pane
unbind K
bind K confirm-before "kill-window"
# redisplay pane
unbind r
bind r refresh-client -S
# sync editing in panes
bind y setw synchronize-panes
# reload this config
bind r source-file ~/.tmux.conf \; display "~/.tmux.conf reloaded"
# resize panes up/down/left/right
bind -r + resize-pane -D 5
bind -r - resize-pane -U 5
bind -r < resize-pane -L 5
bind -r > resize-pane -R 5
# renumber windows after closing
set -g renumber-windows on
# movement (like vim)
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
# swap a window with another
bind s command-prompt -p "send window to:" "swap-window -t '%%'"
# move windows left and right with <,>
bind-key -r [ swap-window -t -
bind-key -r ] swap-window -t +
# tile all panes evenly
bind T select-layout tiled
# cycle panes
unbind ^B
bind ^B select-pane -t :.+
# smart hjkl pane switching with awareness of vim splits and fzf
# https://blog.bugsnag.com/tmux-and-vim/
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 -n C-h run "($is_vim && tmux send-keys C-h) || tmux select-pane -L"
bind -n C-j run "($is_vim && tmux send-keys C-j) || ($is_fzf && tmux send-keys C-j) || tmux select-pane -D"
bind -n C-k run "($is_vim && tmux send-keys C-k) || ($is_fzf && tmux send-keys C-k) || tmux select-pane -U"
bind -n C-l run "($is_vim && tmux send-keys C-l) || tmux select-pane -R"
# toggle last (even in vim)
bind -n C-_ select-pane -l
# create pane splits with |=
unbind %
bind | split-window -h -c "#{pane_current_path}"
bind = split-window -v -c "#{pane_current_path}"
# main vertical sizes
set -gw main-pane-width 150
# enable focus events for a hooks
set -g focus-events on
# update tmux status with VCS info for the current pane
#set-hook -ug pane-focus-in # uncomment to reset hook
set-hook -g pane-focus-in 'run-shell -b "~/.tmux/hooks/pane_focus_in #{pane_current_path}"'
# # source tmux theme
source ~/.tmux/theme.tmux
# tmux plugins (managed with tpm; https://github.com/tmux-plugins/tpm)
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'soyuka/tmux-current-pane-hostname'
# ressurect some programs
set -g @resurrect-processes 'ssh psql mysql irb "~foreman->foreman start" "~rails server->rails server" "~rails console->rails console"'
set -g @resurrect-save 'S'
set -g @resurrect-restore 'R'
# initialize TMUX plugin manager (keep at bottom)
run -b '~/.tmux/plugins/tpm/tpm'