-
Notifications
You must be signed in to change notification settings - Fork 0
/
.tmux.conf
165 lines (135 loc) · 8.2 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
# change bind key from C-b to C-a
unbind C-b
set -g prefix C-a
bind C-a send-prefix
# version-specific stuff
run-shell 'tmux setenv -g TMUX_VERSION $(tmux -V | \
sed -En "s/^tmux ([0-9]+(.[0-9]+)?).*/\1/p")'
if-shell -b '[ "$(echo "$TMUX_VERSION < 2.4" | bc)" = 1 ]' " \
bind -T copy-mode-vi 'v' send -X begin-selection; \
bind -T copy-mode-vi 'y' send -X copy-selection; \
set-window-option -g mode-mouse on; \
set-window-option -g pane-active-border-fg colour166;"
set-option -g escape-time 0 # allows for faster key repetition
set-option -g display-time 4000 # messages are displayed for 4 seconds
set-option -g history-limit 20000 # increase scrollback buffer
set-option -g status-interval 5 # refresh status-left and -right more often
set-option -g base-index 1 # windows start at 1, not 0
set-option -g visual-activity off # don't flash when other panes change
set-option -g visual-bell on # do flash when term would ring
set-option -g renumber-windows on # when a window closes, change numbers to match
set-option -g allow-rename off # programs can't change the window title (we still can, though)
#set-option -g default-terminal "screen-256color" # fix nested tmux vim colors
set-option -g focus-events on
set -ga terminal-features "*:hyperlinks" # enable OSC hyperlinks
set-window-option -g aggressive-resize on # useful when using grouped sessions and multi-monitor setup
set-window-option -g pane-active-border-style "fg=colour166" # outline for active pane
set-window-option -g mouse on # enables mouse support to change windows & resize splits
set-window-option -g pane-base-index 1 # make pane numbering consistent with windows
set-window-option -g mode-keys vi # i want to use vi-style mappings
set-window-option -g automatic-rename off # don't automatically change window title based on running program
set-window-option -g status-bg "blue" # status bar background is blue
# Make p behave like vim paste
unbind p
bind p paste-buffer
bind b list-buffers # list paste buffers
bind B choose-buffer # choose which buffer to paste from
bind r source-file ~/.tmux.conf # re-source this file with C-a r
bind C-s command-prompt -p "Hostname:" "new-window -n '%1' 'ssh -A %1'" # C-a, C-s will prompt for a hostname and then ssh to it
bind C-m command-prompt -p "Hostname:" "new-window -n '%1' 'mosh %1'" # C-a, C-m will prompt for a hostname and `mosh` to it.
bind C-p new-window -n pwsh 'pwsh' # C-a, C-p will open a powershell tab
bind C-c new-window # C-a, C-c creates a new window
bind '|' split-window -h -c "#{pane_current_path}" # C-a, | creates a horizontal split
bind '-' split-window -v -c "#{pane_current_path}" # C-a, - creates a vertical split
bind C-"\\" split-window -h 'HOST=`tmux display-message -p "#W"` && ssh -A $HOST'
bind C-"_" split-window -v 'HOST=`tmux display-message -p "#W"` && ssh -A $HOST'
unbind '"' # unbind default split keys
unbind % # unbind default split keys
bind > swap-pane -D # swap current pane with next one
bind < swap-pane -U # swap current pane with previous one
# C-a, hjkl - vim-style pane nav
bind h select-pane -L
bind l select-pane -R
bind k select-pane -U
bind j select-pane -D
# pane resizing
bind -r H resize-pane -L 2
bind -r J resize-pane -D 2
bind -r K resize-pane -U 2
bind -r L resize-pane -R 2
bind F command-prompt -p "join pane from:" "join-pane -s '%%'" # C-a, J will prompt for a window number and move its contents to this window
bind S command-prompt -p "send pane to:" "join-pane -t '%%'" # C-a, S will prmopt for a window number and move this pane to that window
bind C set-window-option synchronize-panes # C-a, C will send your keystrokes to every pane in the current window. WEAPONIZED TMUX.
bind -n C-J display-popup -E 'tms switch' # run fuzzy window switcher with just C-J (-n says no prefix)
bind -n C-K run-shell 'tmux neww tmux-sessionizer' # (-n says no prefix)
# idea: bind -n C-f run-shell 'tmux neww dotfiles-fzf.sh'
# Remember: C-a M-{1..5} (meta is esc on Mac, alt otherwise) are various resizing schemes
# Remember: C-a $ renames a session
# Remember: C-a , renames a window
bind Escape copy-mode # Can do C-a, esc to enter scrollback/"visual" mode
## from https://github.com/samoshkin/tmux-config/blob/master/tmux/tmux.conf
# Link window
#bind L command-prompt -p "Link window from (session:window): " "link-window -s %% -a"
# kill pane/window shortcuts
bind x kill-pane
bind X kill-window
# nesting local and remote sessions
# Session is considered to be remote when we ssh into host
if-shell 'test -n "$SSH_CLIENT" && [[ "$HOST" != "vm-bschafer" ]]' \
'source-file ~/.tmux/tmux.remote.conf'
# We want to have single prefix key "C-a", usable both for local and remote session
# we don't want to "C-a" + "a" approach either
# Idea is to turn off all key bindings and prefix handling on local session,
# so that all keystrokes are passed to inner/remote session
# see: toggle on/off all keybindings · Issue #237 · tmux/tmux - https://github.com/tmux/tmux/issues/237
# Also, change some visual styles when window keys are off
bind -T root F12 \
set prefix None \;\
set key-table off \;\
set status-style "fg=colour245,bg=colour238" \;\
set window-status-current-format "#[fg=colour238,bg=colour254]|#[default] #I:#W# #[fg=colour254,bg=colour238]|#[default]" \;\
set window-status-current-style "fg=colour232,bold,bg=colour254" \;\
if -F '#{pane_in_mode}' 'send-keys -X cancel' \;\
refresh-client -S \;\
bind -T off 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
# end section special remote handling
# logging config
# if it's not working on macos, go into iterm settings -> profiles -> keys and map L & R option to Esc+
set-option -g @logging-path "$HOME/tmux-logs"
# end section logging config
# plugins
# these are all github paths.
# some may supercede above options, which are in place in case we don't have plugins.
set -g @plugin 'tmux-plugins/tpm' # tmux plugin manager
set -g @plugin 'catppuccin/tmux#v0.2.0' # colors
set -g @plugin 'tmux-plugins/tmux-continuum' # helps autorestore tmux sessions
set -g @plugin 'tmux-plugins/tmux-copycat' # Better copypasta
set -g @plugin 'tmux-plugins/tmux-cpu' # Enables CPU percentage in status bar
set -g @plugin 'tmux-plugins/tmux-logging' # Enables logging commands, e.g. log all terminal output to file
set -g @plugin 'tmux-plugins/tmux-resurrect' # autosaves tmux layout and such
set -g @plugin 'jaclu/tmux-power-zoom' # "zoom" pops pane into its own window
set -g @plugin 'nhdaly/tmux-better-mouse-mode' # exactly what you'd expect
set -g @plugin 'morantron/tmux-fingers' # fancy copypasta with C-a, F
set -g @continuum-restore 'on'
set -g @resurrect-save C-M-s
# status bars
set -g @catppuccin_custom_plugin_dir "~/.tmux/plugins/catppuccin-custom"
set -g @catppuccin_flavor 'frappe'
set -g @catppuccin_status_justify "centre" # put window list in the center of the bar
set -g @catppuccin_window_status "icon" # use status icons for active, previous, zoomed, etc.
set -g @catppuccin_window_current_text " #W" # use my own name for windows
set -g @catppuccin_window_default_text " #W" # use my own name for windows
set -g @catppuccin_window_left_separator "" # character at left of window
set -g @catppuccin_window_right_separator " " # character at right of window
set -g @catppuccin_status_modules_left "host"
set -g @catppuccin_status_modules_right "directory cpu prefix"
set -g @catppuccin_status_right_separator " "
set -g @catppuccin_status_connect_separator "no" # makes status modules look like pills
# keep this line at the bottom
run -b '~/.tmux/plugins/tpm/tpm'