-
Notifications
You must be signed in to change notification settings - Fork 1
/
.tmux.conf
139 lines (115 loc) · 5.74 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
set -sg escape-time 0
set -g history-limit 999999
# remap prefix
unbind C-b
set-option -g prefix C-t
bind-key C-z send-prefix
bind -n S-Left previous-window
bind -n S-Right next-window
set -g mouse on
unbind -T copy-mode-vi MouseDragEnd1Pane
bind -T copy-mode-vi MouseDown1Pane select-pane \;\
send-keys -X copy-pipe "pbcopy" \;\
send-keys -X clear-selection
set-option -g allow-rename off
unbind r
bind r source-file ~/.tmux.conf \; display-message "~/.tmux.conf reloaded" \;
set -g base-index 1
setw -g pane-base-index 1
set-option -g status-position top
set -g status-keys emacs
set -g window-status-separator ''
# Custom title
# Enable names for panes
# Custom command - Do not REMOVE, keep for reference later. custom_title='#{s|HERO_ACCESS_TOKEN=\$HERO_ACCESS_TOKEN_([A-Z]+).*(herocli).*app run-tty|\2 \1|:pane_title}'
set -g pane-border-format "#{pane_index} #{b:pane_current_path}: #T:#{pane_pid}"
# Auto hide pane-border-status line when only one pane is displayed (see tmux/tmux#566)
set-hook -g 'after-new-window' 'run-shell -b "if [ \#{window_panes} -eq 1 ]; then tmux set pane-border-status off; fi"'
set-hook -g 'after-kill-pane' 'run-shell -b "if [ \#{window_panes} -eq 1 ]; then tmux set pane-border-status off; fi"'
set-hook -g 'pane-exited' 'run-shell -b "if [ \#{window_panes} -eq 1 ]; then tmux set pane-border-status off; fi"'
## Smart name for panes, hidden when zoomed or when only have 1 pane
set-hook -g 'after-resize-pane' 'run-shell -b "if [ \#{window_zoomed_flag} -eq 1 ]; then tmux set pane-border-status off; else tmux set pane-border-status top; fi"'
set-hook -g 'window-pane-changed' 'run-shell -b "if [ \#{window_zoomed_flag} -eq 1 ]; then tmux set pane-border-status off; else tmux set pane-border-status top; fi"'
bind-key -T prefix h select-pane -L
bind-key -T prefix l select-pane -R
bind-key -T prefix j select-pane -D
bind-key -T prefix k select-pane -U
bind-key -T prefix / copy-mode \; command-prompt -p "(search down)" "send -X search-forward \"%%%\""
bind-key -T copy-mode-vi C-h select-pane -L
bind-key -T copy-mode-vi C-l select-pane -R
set -g @plugin 'tmux-plugins/tmux-pain-control'
set -g default-terminal 'screen-256color'
set -ga terminal-overrides ',*:Ss=\E[%p1%d q:Se=\E[2 q'
set-option -g renumber-windows on
setw -g mode-keys vi
#
bind-key -T copy-mode-vi v send-keys -X begin-selection
# Copy mode for mac
bind -T copy-mode-vi y send-keys -X copy-pipe 'perl -0 -pe "s/\n\Z//" | pbcopy'
bind -T copy-mode-vi Y send-keys -X copy-pipe-and-cancel 'perl -0 -pe "s/\n\Z//" | pbcopy'
bind -n M-c send-keys 'C-l' \; clear-history
bind -n M-h set-option -g status #Ctrl+F3 Combo
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$'"
is_ssh="ps -o state= -o comm= -t '#{pane_tty}' \
| grep -iqE '^[^TXZ ]+ +(\\S+\\/)?ssh$'"
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) || \
($is_ssh && 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) || \
($is_ssh && 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"
# Go to previous pane
bind -n "C-\\" run "tmux select-pane -l"
# Shortcut to switch pance faster
bind -n M-1 run "tmux select-pane -t 1"
bind -n M-2 run "tmux select-pane -t 2"
bind -n M-3 run "tmux select-pane -t 3"
bind -n M-4 run "tmux select-pane -t 4"
bind -n M-5 run "tmux select-pane -t 5"
bind -n M-6 run "tmux select-pane -t 6"
# Utility from a Minh
bind -n f12 run "if [[ `tmux list-panes -F '#{pane_id}' | wc -l | sed 's/ //g'` == "2" ]]; then (((tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)n?vim(diff)?$|emacs.*$' && tmux send-keys C-k) || tmux select-pane -U) && tmux resize-pane -Z); else tmux split-window -p 40 -c '#{pane_current_path}'; fi "
is_htop="ps -o state= -o comm= -t '#{pane_tty}' \
| grep -iqE '^[^TXZ ]+ +(\\S+\\/)?htop$'"
bind -n f10 run "($is_htop && tmux send-keys f10) || \
tmux resize-pane -Z"
bind -n M-0 run "tmux resize-pane -Z"
bind-key -T prefix C-t run "tmux resize-pane -Z"
# Custom for the theme, need kill-server to change affect
set -g @themepack-status-left-area-left-format "Session #S"
set -g @themepack-status-left-area-middle-format "#{pane_index}/#{window_panes}"
set -g @themepack-status-left-area-right-format ""
set -g @themepack-status-right-area-left-format ""
set -g @themepack-status-right-area-right-format "#{online_status}"
set -g @themepack-status-right-area-middle-format " #{lunar_date}"
set -g @powerline-status-right-area-right-bg "#{@powerline-color-grey-4}"
set -g @plugin "jimeh/tmux-themepack"
set -g @themepack 'powerline/double/green'
set -g @plugin 'tmux-plugins/tmux-online-status'
set -g @plugin 'codeaholicguy/tmux-tet'
# Resume/Restore session after kill/restart
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'tmux-plugins/tmux-continuum'
# Tmux easymotion style
set -g @jump-key 's'
set -g @plugin 'schasse/tmux-jump'
# Tmux logging to file
#Use custom version to avoid lagging
set -g @plugin 'tmux-plugins/tmux-logging'
set -g default-shell $SHELL
# #
# set -g default-command "reattach-to-user-namespace -l ${SHELL}"
# Plugin list
set -g @plugin 'tmux-plugins/tpm'
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
# If missing, please clone it at here: git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
run -b '~/.tmux/plugins/tpm/tpm'