-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.tmux.conf
170 lines (151 loc) · 7.24 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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
# Configuring tmux based on the environment:
# https://stackoverflow.com/a/40902312
run-shell "tmux setenv -g TMUX_VERSION $(tmux -V | perl -lne 'print $& if /[\d.]+/')"
#tmux attach -t main || tmux new -s main
#if tmux in kitty throws "open terminal failed: can't find terminfo database", start tmux with -L<any socket name> flag instead
#/usr/local/bin/tmux new-session -A -s main
unbind C-b
set-option -g prefix `
bind ` send-prefix
bind R source-file ~/.tmux.conf\; display "Reloaded!" #reload configuration
bind h select-pane -L #vim style pane navigation
bind j select-pane -D #vim style pane navigation
bind k select-pane -U #vim style pane navigation
bind l select-pane -R #vim style pane navigation
bind e last-window #replaces <prefix>l
bind C-k clear-history #clear scrollback buffer
# <prefix>! to break current pane into its own window
bind-key @ break-pane \; last-window #break current pane into another window
bind-key S choose-window 'join-pane -v -s "%%"' #join a window into a pane Split horizontally
bind-key V choose-window 'join-pane -h -s "%%"' #join a window into a pane split Vertically
bind-key M-s new
set -sg escape-time 0 #set escape delay (lag) to 0
#set -g status off
bind-key \ set status
set -g focus-events on
set -g default-terminal "screen-256color"
set-option -g renumber-windows on
set-option -g default-shell /bin/zsh
if-shell "uname | grep -q Linux" "set-option -g default-shell /usr/bin/zsh"
set -g -a terminal-overrides ',*:Ss=\E[%p1%d q:Se=\E[2 q' #enable nvim guicursor to work
set-option -g history-limit 10000 #default 2000
set -g mouse on
# sane scrolling:
bind -n WheelUpPane if-shell -F -t = "#{mouse_any_flag}" "send-keys -M" "if -Ft= '#{pane_in_mode}' 'send-keys -M' 'copy-mode -e; send-keys -M'"
# copy mode
setw -g mode-keys vi
bind-key -T copy-mode-vi 'v' send -X begin-selection
if-shell "uname | grep -q Darwin" "bind-key -T copy-mode-vi 'y' send -X copy-pipe 'pbcopy'"
if-shell "uname | grep -q Linux" "bind-key -T copy-mode-vi 'y' send -X copy-pipe 'xsel'"
unbind-key -T copy-mode-vi MouseDragEnd1Pane
#Statusbar
if-shell -bF '[ $(bc <<< "$TMUX_VERSION >= 2.9") -eq 1 ]' \
"\
set -g status-style bg=colour16,fg=colour103;\
set -g window-status-current-style bg=colour16,fg=colour103,bold,underscore;\
set -g window-status-style bg=colour16,fg=colour103;\
" "\
set -g status-bg colour16;\
set -g status-fg colour103;\
setw -g window-status-current-bg colour16;\
setw -g window-status-current-fg colour103;\
setw -g window-status-current-attr bold,underscore;\
setw -g window-status-bg colour16;\
setw -g window-status-fg colour103;\
"
# set -g status-bg colour16
# set -g status-fg colour103
# setw -g window-status-current-attr bold,underscore
# setw -g window-status-current-bg colour16
# setw -g window-status-current-fg colour103
# setw -g window-status-bg colour16
# setw -g window-status-fg colour103
# set -g status-right '#{battery_status_bg} #{battery_icon} #{battery_percentage} #{battery_remain} | %a %h-%d %H:%M '
# set -g status-right '#{battery_icon} #{battery_percentage}|%a %h-%d %H:%M'
# set -g status-right 'batt:#{battery_percentage}|%a %h-%d %H:%M'
set -g status-right '#{battery_percentage} %a %h-%d %H:%M'
set status-left-length 30 #extend max length for session name
#Easy window moving
bind-key M-[ swap-window -t -1
bind-key M-] swap-window -t +1
bind-key M choose-tree -Zw "join-pane -s '%%'"
bind-key C-m choose-tree -Zw "join-pane -t '%%'"
#New windows/panes follow CWD
bind-key c new-window -c '#{pane_current_path}'
bind-key '"' split-window -c '#{pane_current_path}'
bind-key % split-window -h -c '#{pane_current_path}'
# Smart pane switching with awareness of Vim splits.
# 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 M-h if-shell "$is_vim" "send-keys M-h" "select-pane -L"
bind-key -n M-j if-shell "$is_vim" "send-keys M-j" "select-pane -D"
bind-key -n M-k if-shell "$is_vim" "send-keys M-k" "select-pane -U"
bind-key -n M-l if-shell "$is_vim" "send-keys M-l" "select-pane -R"
bind-key -n M-\ if-shell "$is_vim" "send-keys M-\\" "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
# Scripting
# (https://superuser.com/q/1069335) tmux list-panes -s -F '#{window_index} #{pane_index} #{pane_current_path}'
#Sessions
#tmux ls list sessions
#tmux new -s <session_name> new session
#tmux a -t <session_name> attach to session
#tmux kill-session -t <session_name> kill specific session
#tmux kill-server kill all tmux sessions
#C-b s list current sessions
#C-b $ rename current session
#C-b d detach session
#C-b ( previous session
#C-b ) next session
#C-b L Last session
#Panes
#C-b " split vertically (top/bottom)
#C-b % split horizontally (left/right)
#C-b x kill pane
#C-b o go to the next pane (cycle through all of them)
#C-b ; go to the ‘last’ (previously used) pane
#C-b q show pane numbers
#C-b z pane zoom
##Moving
#C-b { move current pane to previous position
#C-b } move current pane to next position
##Resizing
#C-b <M-dir> resize pane in <direction> 5 units at a time
#C-b <M-1> resize all panes equally (vertically)
#C-b <M-2> resize all panes equally (horizontally)
#C-b <M-5> resize all panes (tiled)
#Windows
#C-b ! break current pane into its own window
#C-b <0-9> switch to window number <0-9>
#C-b n switch to next window in list
#C-b p switch to previous window in list
#C-b l switch to last used window
#C-b & kill current window
#C-b , rename current window
#Misc
#C-b ? list shortcuts
#C-b : show prompt
#Realtime Session Sharing (http://www.hamvocke.com/blog/remote-pair-programming-with-tmux/)
#tmux new -s shared_alice #create a shared session called 'shared_alice"
#tmux new -s shared_bob -t shared_alice #'shared_bob' is a new session synchronized with 'shared_alice'
# List of plugins
set -g @plugin 'tmux-plugins/tpm'
# set -g @plugin 'tmux-plugins/tmux-sensible'
# set -g @plugin 'tmux-plugins/tmux-resurrect'
# # set -g @resurrect-capture-pane-contents 'on'
# # set -g @resurrect-save-shell-history 'on'
# # set -g @resurrect-strategy-nvim 'session'
# set -g @plugin 'tmux-plugins/tmux-continuum'
set -g @plugin 'tmux-plugins/tmux-battery'
# set -g @plugin 'nhdaly/tmux-better-mouse-mode'
# set -g @plugin 'tmux-plugins/tmux-yank'
# Other examples:
# set -g @plugin 'github_username/plugin_name'
# set -g @plugin 'git@github.com/user/plugin'
# set -g @plugin 'git@bitbucket.com/user/plugin'
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'