-
Notifications
You must be signed in to change notification settings - Fork 0
/
.tmux.conf
138 lines (113 loc) · 5.64 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
############
# Binds
############
unbind C-b
set -g prefix C-s
bind-key -r C-s send-prefix
bind-key r source-file ~/.tmux.conf \; display-message "~/.tmux.conf reloaded"
bind-key c new-window -c "#{pane_current_path}" # Open new windows at the same path as the pane they were created from.
unbind x
bind-key x split-window -v -c "#{pane_current_path}" # Create a new pane below the current one.
bind-key v split-window -h -c "#{pane_current_path}" # Create a new pane to the right of the current one.
# Switch windows with shift-arrow
bind-key -n S-Left previous-window
bind-key -n S-Right next-window
# Reorder windows with ctrl-shift-arrow.
bind-key -n C-S-Left { swap-window -t -1; previous-window }
bind-key -n C-S-Right { swap-window -t +1; next-window }
# Resize panes.
# I don't think these should be necessary; we're mapping them in the smart-splits config below.
# But the keybinding doesn't work without these here.
bind-key -n M-Left resize-pane -L 5
bind-key -n M-Right resize-pane -R 5
bind-key -n M-Down resize-pane -D 3
bind-key -n M-Up resize-pane -U 3
bind-key j choose-session # View all open sessions.
bind-key J choose-tree # View all open sessions and open windows.
unbind d # Remove default lowercase d binding for detaching the session.
bind-key D detach # Detach the current session.
bind-key e split-window -h -c "#{pane_current_path}" "nvim" # Open neovim in a new pane to the right for the current directory.
# Manage panes.
bind-key > swap-pane -D
bind-key < swap-pane -U
bind-key a display-panes\; command-prompt -p "pane #: " "swap-pane -t '%%'"
bind-key b break-pane # Break the current pane out to a new window.
bind-key B send-keys 'tat && exit' 'C-m' # Break the current pane out to a new session.
# Kill the current session and then switch to a different session. If there are no other sessions, tmux closes.
bind-key K run-shell 'tmux switch-client -n \; kill-session -t "$(tmux display-message -p "#S")" || tmux kill-session'
# mrjones2014/smart-splits.nvim
# '@pane-is-vim' is a pane-local option that is set by the plugin on load,
# and unset when Neovim exits or suspends; note that this means you'll probably
# not want to lazy-load smart-splits.nvim, as the variable won't be set until
# the plugin is loaded
bind-key -n C-h if -F "#{@pane-is-vim}" 'send-keys C-h' 'select-pane -L'
bind-key -n C-j if -F "#{@pane-is-vim}" 'send-keys C-j' 'select-pane -D'
bind-key -n C-k if -F "#{@pane-is-vim}" 'send-keys C-k' 'select-pane -U'
bind-key -n C-l if -F "#{@pane-is-vim}" 'send-keys C-l' 'select-pane -R'
bind-key -n M-h if -F "#{@pane-is-vim}" 'send-keys M-h' 'resize-pane -L 3'
bind-key -n M-j if -F "#{@pane-is-vim}" 'send-keys M-j' 'resize-pane -D 3'
bind-key -n M-k if -F "#{@pane-is-vim}" 'send-keys M-k' 'resize-pane -U 3'
bind-key -n M-l if -F "#{@pane-is-vim}" 'send-keys M-l' 'resize-pane -R 3'
tmux_version='$(tmux -V | sed -En "s/^tmux ([0-9]+(.[0-9]+)?).*/\1/p")'
if-shell -b '[ "$(echo "$tmux_version < 3.0" | bc)" = 1 ]' \
"bind-key -n 'C-\\' if -F \"#{@pane-is-vim}\" 'send-keys C-\\' 'select-pane -l'"
if-shell -b '[ "$(echo "$tmux_version >= 3.0" | bc)" = 1 ]' \
"bind-key -n 'C-\\' if -F \"#{@pane-is-vim}\" 'send-keys C-\\\\' '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
##########
# Options
##########
set-option -sg escape-time 0 # Remove delay after hitting escape. Essential if you're using vim.
set-option -g allow-rename off # Don't overwrite user created window names.
set-option -g default-shell /bin/zsh
set-option -g focus-events on # Neovim :checkhealth recommended setting this so `autoread` will work.
set-option -g display-time 3000 # Increase tmux messages display duration from 750ms to 4s
############
# Theme
############
set-option -sa terminal-overrides ',xterm-256color:RGB'
# Modes
setw -g clock-mode-colour colour135
setw -g mode-style fg=colour196,bg=colour238,bold
# Messages
set -g message-style fg=colour232,bg=colour166,bold
set -g message-command-style fg=blue,bg=black
# Panes
set -g pane-border-style fg=colour7
set -g pane-active-border-style fg=colour209
# Status Line
set-option -g renumber-windows on # Renumber windows as they are created and destroyed.
set-option -g base-index 1 # Use 1 based indexing for windows.
set-option -g pane-base-index 1 # Use 1 based indexing for panes.
set -g status-justify left
set -g status-interval 1
set -g status-left " Session: #S "
set -g status-position bottom
set -g status-style fg=colour52,bg=colour253
set -g status-left-length 80
set -g status-right '#[fg=colour0,bg=colour255] Battery: #{battery_percentage} #[fg=colour0,bg=colour15] %A %B %d %l:%M:%S %p '
set -g status-right-length 80
setw -g window-status-current-style fg=colour22,bg=colour231,bold
setw -g window-status-current-format ' #I#[fg=colour250]:#[fg=colour232]#W#[fg=colour52]#F '
setw -g window-status-style fg=colour138,bg=colour255,none
setw -g window-status-format ' #I#[fg=colour237]:#[fg=colour237]#W#[fg=colour244]#F '
setw -g window-status-bell-style fg=colour255,bg=colour1,bold
##########
# Copy Mode
##########
set -g mouse on
set -g history-limit 10000
# # Vi copypaste
setw -g mode-keys vi
bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "reattach-to-user-namespace pbcopy"
bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel "reattach-to-user-namespace pbcopy" \; display-message "highlighted selection copied to system clipboard"
############
# Plugins
############
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-battery'
run '~/.tmux/plugins/tpm/tpm'