-
Notifications
You must be signed in to change notification settings - Fork 1
/
.tmux.conf
154 lines (129 loc) · 4.65 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
# =====================================
# === General ===
# =====================================
# TrueColor
# set-option -ga terminal-overrides "xterm-256color"
set-window-option -g xterm-keys on
setw -g mode-keys vi
set -g mouse on
set -s escape-time 0
set -s focus-events on
# cmd+c and drag/drop support
set -g default-command "reattach-to-user-namespace -l fish"
# count from 1
set -g base-index 1
setw -g pane-base-index 1
# iterm tab name
set -g set-titles on
setw -g set-titles-string "#S"
# for conditional binding
is_vim="run-shell ps -o state= -o comm= -t '#{pane_tty}' | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"
# =====================================
# === Plugins ===
# =====================================
set-environment -g TMUX_PLUGIN_MANAGER_PATH '~/.config/tmux/plugins/'
# tmux autostart and saving sessions between reebots
set -g @continuum-boot 'on'
set -g @continuum-restore 'on'
set -g @continuum-boot-options 'iterm'
set -g @resurrect-capture-pane-contents 'on'
set -g @resurrect-strategy-nvim 'session'
set -g @resurrect-strategy-vim 'session'
# Status Line
set -g @themepack 'mytheme'
set -g @tmp-clean 'u'
set -g @fingers-key 'F'
set -g @jump-key 'J'
# List of plugins
set -g @tpm_plugins ' \
tmux-plugins/tpm \
jimeh/tmux-themepack \
tmux-plugins/tmux-continuum \
tmux-plugins/tmux-copy \
tmux-plugins/tmux-resurrect \
tmux-plugins/tmux-sensible \
tmux-plugins/tmux-sessionist \
tmux-plugins/tmux-yank \
christoomey/vim-tmux-navigator \
NHDaly/tmux-scroll-copy-mode \
Morantron/tmux-fingers \
schasse/tmux-jump \
'
run '~/.config/tmux/plugins/tpm/tpm'
# =====================================
# === Nesting ===
# =====================================
# colors
color_yellow="colour11"
color_black="colour232"
color_grey="colour238"
# separators (from .vimrc)
left_sep="\uE0B4"
left_alt_sep="\uE0B5"
# F12 toggle for nested tmux sessions
bind -T root S-F12 \
set prefix None \;\
set key-table off \;\
set status-style "fg=$color_grey,bg=$color_yellow" \;\
set window-status-current-format "#[default]#[bg=$color_yellow,fg=$color_grey]$left_sep #I $left_alt_sep #W $left_alt_sep #F #[bg=$color_grey,fg=$color_yellow]$left_sep" \;\
set window-status-current-style "fg=$color_black,bold,bg=$color_yellow" \;\
if -F '#{pane_in_mode}' 'send-keys -X cancel' \;\
refresh-client -S \;\
bind -T off S-F12 \
set -u prefix \;\
set -u key-table \;\
set -u status-style \;\
set -u window-status-current-style \;\
set -u window-status-current-format \;\
refresh-client -S
# =====================================
# === Controls ===
# =====================================
# unbind non wanted commands
unbind '"'
unbind %
unbind C-b
unbind p
unbind n
unbind S
unbind C-z
unbind z
unbind =
# remap prefix to Control + a
set -g prefix C-a
bind C-a send-prefix
bind Escape copy-mode
# popus (iterm2 CMD+<key>)
#bind C-g run-shell "tmux popup -E 'lazygit'"
#bind C-c run-shell "tmux popup -E 'tmux new-session -A -s cmus'"
# clear-console
bind C-l send-keys 'C-l'
# PANES
# joining panes
bind h command-prompt -p "join pane from:" "join-pane -v -s '%%'" # join target pane vertically
bind j command-prompt -p "join pane from:" "join-pane -h -s '%%'" # join target pane horizontally
bind d command-prompt -p "detach pane as:" "break-pane -n '%%'" # spits joined panes
# resizing panels
bind z if-shell "$is_vim" "send-keys C-w z" "resize-pane -Z"
bind Z resize-pane -Z
bind -n C-S-Up resize-pane -U 5
bind -n C-S-Down resize-pane -D 5
bind -n C-S-Left resize-pane -L 5
bind -n C-S-Right resize-pane -R 5
# WINDOWS
# window splits
bind S split-window -h -c "#{pane_current_path}"
bind V split-window -v -c "#{pane_current_path}"
bind s if-shell "$is_vim" "send-keys C-w s" "split-window -h -c '#{pane_current_path}'"
bind v if-shell "$is_vim" "send-keys C-w v" "split-window -v -c '#{pane_current_path}'"
bind \\ select-layout even-vertical
bind | select-layout even-horizontal
bind -n S-F1 previous-window
bind -n S-F2 next-window
# swap-windows (tabs) BTT: C-</>
bind -n S-F8 if-shell "$is_vim" "send-keys C-w <"
bind -n S-F9 if-shell "$is_vim" "send-keys C-w >"
bind -n S-F10 { swap-window -t -1; select-window -t -1 }
bind -n S-F11 { swap-window -t +1; select-window -t +1 }
bind x if-shell "$is_vim" "send-keys :qa! Enter" "confirm-before -p 'kill-pane #P? (y/n)' kill-pane"
bind C-j split-window -v "tmux list-sessions | sed -E 's/:.*$//' | grep -v \"^$(tmux display-message -p '#S')\$\" | fzf --reverse | xargs tmux switch-client -t"