-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy path.tmux.conf
153 lines (126 loc) · 7.58 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
# tmux is a terminal application that lets you have multiple "panes" open at once. If you've ever used iTerm
# on OSx, it's like that. Additionally, you can run multiple sessions of tmux and swap between them; though I
# haven't gotten that far yet.
# Important_Bindings
# General_Settings
# Windows/Panes
## Windows
## Panes
# Copy_Mode
# Misc
# References
############################## Important_Bindings ###########
set -g prefix M-a # remap prefix to Control + a
bind M-a send-prefix # bind 'C-a C-a' to type 'C-a'
unbind C-b # remove original binding of C-b
bind r source-file ~/.tmux.conf # reload tmux settings
bind -n M-r source-file ~/.tmux.conf # Alt+Shift+r = reload tmux settings
bind -n M-: command-prompt # Alt+Shift+: = open command-prompt
bind -n M-I display-panes # Alt+Shift+I = Display pane ids
bind -n M-Q kill-session # Alt+Shift+Q = kill session
bind -n M-P detach-client # Alt+Shift+P = "Pause" (Detach) session
# C-k for clear screen (-R resets on-screen terminal, clear-history clears "off screen"), unless vim is running
bind -n C-k if-shell "$is_vim" 'send-keys C-k' 'send-keys -R ; clear-history'
# Alt+Shift+Space in vim full-screens
bind -n M-Space if-shell "$is_vim" 'send-keys "," Enter'
############################## General_Settings ###########
set -sg escape-time 0 # max MS between ESC and next part of command
source-file $ST_TMUX_THEME # Theme file, see flare576/switch-theme project
set -g mouse on # allows mouse clickies
set-option -g base-index 1 # Some plugins conflict with 0-indexed elements
set-window-option -g pane-base-index 1 # Some plugins conflict with 0-indexed elements
############################## Windows/Panes ###########
########################## Windows (Alt+Shift)
# New
bind -n M-| new-window # Alt+Shift+| = open new pane
bind -n M-_ new-window # Alt+Shift+_ = open new pane
# Navigate ← ↓ ↑ →
bind -n M-K select-window -t :^ # « using Alt+Shift+K without prefix
bind -n M-J select-window -t :$ # » using Alt+Shift+J without prefix
bind -n M-H previous-window # ← using Alt+Shift+H without prefix
bind -n M-L next-window # → using Alt+Shift+L without prefix
# Next/Previous
bind -n M-'{' previous-window # ← using Alt+Shift+{ without prefix
bind -n M-'}' next-window # → using Alt+Shift+} without prefix
# Prefix + Enter maximize/restore pane
bind Enter if-shell "[[ #{window_panes} -eq 1 || #{window_zoomed_flag} -eq 1 ]]" "resize-pane -Z" "resize-pane -Z"
bind -n M-Enter if-shell "[[ #{window_panes} -eq 1 || #{window_zoomed_flag} -eq 1 ]]" "resize-pane -Z" "resize-pane -Z"
########################## Panes (Alt)
# New
bind -n M-'\' split-window -h # Alt+\ = split pane horizontal
bind -n M-'-' split-window -v # Alt+- = split pane vertical
# Navigate ← ↓ ↑ →
bind -n M-h select-pane -Z -L # ← using Alt-h without prefix
bind -n M-j select-pane -Z -D # ↓ using Alt-j without prefix
bind -n M-k select-pane -Z -U # ↑ using Alt-k without prefix
bind -n M-l select-pane -Z -R # → using Alt-l without prefix
# Next/Previous
bind -n M-] select-pane -Z -t "{next}" # ↑ using Alt-k without prefix
bind -n M-[ select-pane -Z -t "{previous}" # → using Alt-l without prefix
# Resize
bind -r h resize-pane -L 1 # Prefix -> h = Enlarge to the left
bind -r j resize-pane -D 1 # Prefix -> j = Enlarge down
bind -r k resize-pane -U 1 # Prefix -> h = Enlarge up
bind -r l resize-pane -R 1 # Prefix -> h = Enlarge to the right
# Maximize Pane Size (no undo)
bind _ resize-pane -y 100% # Prefix -> _ = full height pane
bind | resize-pane -x 100% # Prefix -> | = full width pane
# get size
bind -r i display-message -p 'W:#{pane_width}/H:#{pane_height}'
# Modifier then Tab opens pane-select
bind -n M-Tab choose-tree
############################## Copy_Mode ###########
# pbcopy/pbpaste functionality in tmux (for Mac)
osx_copy='send -X copy-pipe-and-cancel "pbcopy"\; copy-selection-and-cancel'
# clip copy functionality for WSL
wsl_copy='send -X copy-pipe-and-cancel "clip.exe"\; copy-selection-and-cancel'
# xclip copy functionality for *Nix
nix_copy='send -X copy-pipe-and-cancel "xclip -in -selection clipboard"\; copy-selection-and-cancel'
omni_copy='if-shell "$is_osx" "$osx_copy" "if-shell \"$is_wsl\" \"$wsl_copy\" \"$nix_copy\""'
# More-like-vim copy mode
set-window-option -g mode-keys vi # vim keys in copy mode
unbind -T copy-mode-vi Enter # Remove default Enter behavior
bind -T copy-mode-vi Enter "$omni_copy" # Map the universal system copy
bind -T copy-mode-vi y "$omni_copy" # Map the universal system copy
bind -T copy-mode-vi MouseDragEnd1Pane "$omni_copy" # Map the universal system copy
bind -T copy-mode-vi v send -X begin-selection # simulates "visual mode" selection
bind -T copy-mode-vi B send -X back-to-indentation # simulates the vim binding "B" to start-of-line
bind -T copy-mode-vi E send -X end-of-line # simulates the vim binding "E" to end-of-line
# By default, `C-v` only changes to rectangle selection
bind -T copy-mode-vi C-v send -X rectangle-toggle\; send -X begin-selection
#tmux buffer paste for Linux for now
bind -n M-V paste-buffer # Alt+Shift+V to paste tmux buffer
############################## Misc ###########
# https://www.bugsnag.com/blog/tmux-and-vim
is_vim="ps -o state= -o comm= -t '#{pane_tty}' | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"
is_wsl="command -v clip.exe"
is_osx="command -v pbcopy"
# When on a docker image (or anything els you want quick access to scripts/tools < 2minute script
bind -r b send-keys 'apt-get update &> /dev/null;apt-get install -y --no-install-recommends ca-certificates curl &> /dev/null;bash -c "$(curl -sSL https://raw.githubusercontent.com/Flare576/dotfiles/main/setup/NIX/os_ubuntu_remote.sh)"'
# Rotary Encode mapping to Copy mode
bind -n Home copy-mode
# Plugin management
set -g @plugin 'tmux-plugins/tpm'
set -g @resurrect-strategy-vim 'session'
set -g @plugin 'tmux-plugins/tmux-sensible'
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'
############################## Resources ###########
# Further reading
# Basic tutorials
# https://lukaszwrobel.pl/blog/tmux-tutorial-split-terminal-windows-easily/
# Status line
# https://medium.com/hackernoon/customizing-tmux-b3d2a5050207
# Copy/Paste
# https://thoughtbot.com/blog/tmux-copy-paste-on-os-x-a-better-future
# Example config
# https://github.com/c02y/dotfiles/blob/master/tmux/.tmux.conf
# Escape Delay suggestions
# https://www.johnhawthorn.com/2012/09/vi-escape-delays/
# Color palette
# https://superuser.com/questions/285381/how-does-the-tmux-color-palette-work
# Copy mode bindings
# https://superuser.com/questions/395158/tmux-copy-mode-select-text-block
# Variables and conditionals
# https://superuser.com/questions/1456540/toggle-a-pane-in-tmux
# https://stackoverflow.com/questions/25909964/tmux-how-to-toggle-on-and-off-options-with-the-same-key