-
Notifications
You must be signed in to change notification settings - Fork 1
/
tmux.conf
151 lines (130 loc) · 5.48 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
set -g prefix C-s # Change prefix key to C-s
unbind C-b
set -sg escape-time 1 # keystroke delay
bind r source-file ~/.config/tmux/tmux.conf \; display "Reloaded!" # reload config file in current session
bind C-s send-prefix # send C-s to nested sessions
set -g history-limit 10000
##### KEYBINDS
# Alias to arrow keys
bind -n 'C-j' send-keys Down
bind -n 'C-k' send-keys Up
### PANE
# Movement between panes
is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
| grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|nvim)(diff)?$'"
bind -n 'M-h' if-shell "$is_vim" 'send-keys M-h' 'select-pane -L'
bind -n 'M-j' if-shell "$is_vim" 'send-keys M-j' 'select-pane -D'
bind -n 'M-k' if-shell "$is_vim" 'send-keys M-k' 'select-pane -U'
bind -n 'M-l' if-shell "$is_vim" 'send-keys M-l' 'select-pane -R'
bind -T copy-mode-vi 'M-h' select-pane -L
bind -T copy-mode-vi 'M-j' select-pane -D
bind -T copy-mode-vi 'M-k' select-pane -U
bind -T copy-mode-vi 'M-l' select-pane -R
# Change size of pane
bind -r < resize-pane -L 5
bind -r > resize-pane -R 5
bind -r = resize-pane -D 5
bind -r + resize-pane -U 5
# Create new pane; copy cwd
bind -n M-v split-window -vc "#{pane_current_path}"
bind -n M-b split-window -hc "#{pane_current_path}"
bind -n M-y split-window -hc "#{pane_current_path}" \; resize-pane -x 100
bind -n M-t split-window -vc "#{pane_current_path}" \; resize-pane -y 16
bind | split-window -h
bind - split-window -v
# Kill pane
bind -n M-x kill-pane
# Zoom pane
bind -n M-z resize-pane -Z
### SCRATCH BUFFER
bind -n M-w display-popup -w "80%" -h "80%" -E "tmux new-session -A -s scratch"
bind -n M-r display-popup -w "90%" -h "95%" -E "tmux new-session -A -s monitor"
### WINDOWS
# Create new window; copy cwd
bind -n M-c new-window -c '#{pane_current_path}'
# Movement between windows
bind -n M-, select-window -t :-
bind -n M-\; select-window -t :+
bind -n M-0 select-window -t 0
bind -n M-1 select-window -t 1
bind -n M-2 select-window -t 2
bind -n M-3 select-window -t 3
bind -n M-4 select-window -t 4
bind -n M-5 select-window -t 5
bind -n M-6 select-window -t 6
bind -n M-7 select-window -t 7
bind -n M-8 select-window -t 8
bind -n M-9 select-window -t 9
# Delete Windows
bind X kill-window
### SESSIONS
# Detach session
bind -n M-d detach-client
# Switch session
bind -n M-s run-shell 'tmux choose-tree -swZ -O time -f "##{!=:##{session_name},#{session_name}}"'
bind -n M-i switch-client -l
### COPY MODE
bind -n M-m copy-mode -e # enter copy mode keybind
bind -n M-p run "xclip -o | tmux load-buffer - ; tmux paste-buffer" # paste from system clipboard
##### OTHER CONFIGURATIONS
# Enable mouse and mouse scroll
setw -g mouse on
bind -n WheelUpPane if-shell -F -t = "#{mouse_any_flag}" "send-keys -M" "if -Ft= '#{pane_in_mode}' 'send-keys -M' 'copy-mode -e'"
bind -n WheelDownPane select-pane -t= \; send-keys -M
# terminal color
set -g default-terminal "tmux-256color"
set -ga terminal-overrides ',*:Tc' # this is for 256 color
set -ga terminal-overrides '*:Ss=\E[%p1%d q:Se=\E[ q' # this is for the cursor shape
# neovim config
set -g focus-events on
# Start window numbers from 1
set -g base-index 1
set -g pane-base-index 1
setw -g pane-base-index 1
# Status Bar
set -g status-position top
set -g status-left-length 40
set -g status-left "#[fg=green]#S #[fg=yellow]#I #[fg=cyan]#P #[fg=gray] "
set -g status-right-length 120
# NOTE: cut -c 1-$((120-24))
set -g status-right "#[fg=blue]#(( [ `uname` = 'Darwin' ] && command ps -o command -t '#{pane_tty}' | tail -1 || command ps ho cmd --ppid `tmux display -p '#{pane_pid}'` ) | cut -c 1-96) #[fg=white][%Y-%m-%d(%a) %H:%M]"
set -g status-interval 15 # Refresh seconds of status bar
# Color of status bar (transparent status bar)
set -g status-style bg=default
# Color of window list
setw -g window-status-style bg=default,dim,fg=cyan
setw -g window-status-current-style bg=red,bright,fg=white
# Color of pane border (line between panes)
set -g pane-border-style fg=white
set -g pane-active-border-style fg=yellow
# Color of terminal outputs
set -g message-style bg=black,bright,fg=white
# Visuals on, image support
setw -g monitor-activity on
set -g visual-activity off
set -gq allow-passthrough on
# Use vim keybindings in copy mode
setw -g mode-keys vi
bind-key -T copy-mode-vi v send-keys -X begin-selection
bind-key -T copy-mode-vi V send-keys -X select-line
bind-key -T copy-mode-vi C-v send-keys -X rectangle-toggle
bind-key -T copy-mode-vi Escape send-keys -X cancel
bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "clip-in"
bind-key -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel "clip-in"
bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel "clip-in"
##### Plugins
set-environment -g TMUX_PLUGIN_MANAGER_PATH "${XDG_DATA_HOME}/tmux/plugins"
set -g @suspend_key 'M-q'
set -g @suspend_suspended_options " \
status-left-style::bg=brightblack\\,fg=black bold dim, \
window-status-current-style:gw:bg=brightblack\\,fg=black, \
window-status-last-style:gw:fg=brightblack, \
window-status-style:gw:bg=black\\,fg=brightblack, \
@mode_indicator_custom_prompt:: ---- , \
@mode_indicator_custom_mode_style::bg=brightblack\\,fg=black, \
"
set -g @plugin 'laktak/extrakto' # <tab>: fzf from current pane
set -g @plugin 'pysan3/tmux-copy-toolkit' # S: easycopy, Q: quickcopy, P: quickopen, W: linecopy
set -g @plugin 'MunifTanjim/tmux-suspend' # suspend nested tmux sessions
set -g @plugin 'Morantron/tmux-fingers' # Easy copy for perticular strings `prefix + F`
run "${XDG_DATA_HOME}/tmux/plugins/tpm/tpm"