-
Notifications
You must be signed in to change notification settings - Fork 1
/
tmux.conf
127 lines (96 loc) · 3.98 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
# vi:filetype=tmux
# Initially stolen from github.com/msuriar/dotfiles; thanks, Murali!
# Initial setup...
set-option -g prefix `
unbind-key C-b
unbind-key '"'
unbind-key %
bind-key ` send-prefix # `` to send a `
set-option -g mouse off
# Pane management
## Splits
bind-key _ split-window
bind-key | split-window -h
## Move between panes
bind-key h select-pane -L
bind-key j select-pane -D
bind-key k select-pane -U
bind-key l select-pane -R
## Resize panes
bind-key -r H resize-pane -L 5
bind-key -r J resize-pane -D 5
bind-key -r K resize-pane -U 5
bind-key -r L resize-pane -R 5
## New pane
bind-key b break-pane
## Utility: pipe the pane to a file with the window's name.
bind-key P pipe-pane -o "cat >> $HOME/#W.log" \; display-message "Toggled logging to $HOME/#W.log"
## vi-like copy to xclip, as described at https://unix.stackexchange.com/questions/131011/use-system-clipboard-in-vi-copy-mode-in-tmux
## or better yet, at https://github.com/tmux/tmux/issues/592
bind-key -T copy-mode-vi y send -X copy-pipe-and-cancel 'xclip -in -selection clipboard'
# Window management
bind-key t last-window
## Space: toggle layouts
## Shortcut to a man page; specify the entry.
bind-key / command-prompt "split-window 'exec man %%'"
# Session management
## Start / attach session
bind-key N command-prompt "new-session -A -s '%%'"
# Client & server management
## Reload the source.
bind-key r source-file ~/.tmux.conf
## Status line
set -g status-style fg=black,bg=$SYSCOLOR
set -g pane-active-border-style fg=$SYSCOLOR
# Color control;
# per https://gist.github.com/andersevenrud/015e61af2fd264371032763d4ed965b6
set -g default-terminal "tmux-256color"
set -ga terminal-overrides ",xterm-256color:RGB"
set -ga terminal-overrides ",alacritty:RGB"
# Start windows and panes at 1 rather than 0. Easier to type, with ` on that
# side.
set -g base-index 1
setw -g pane-base-index 1
# Reverse of 'b': join the other pane to this one
bind-key B command-prompt "join-pane -h -s '%%'"
# Strong version of 'd'; 'kill session' rather than 'disconnect but leave it around to reconnect to'
bind-key D kill-session
# Create a side pane, appropriately sized for a commit message
bind-key v split -h \; resize-pane -t:.2 -x 54
# Toggle status bar
bind-key \\ set -g status
# Things that I don't yet understand...
set-option -g history-limit 90000
set-option -s escape-time 1
set-window-option -g aggressive-resize on
set-option -g status-keys vi
set-window-option -g mode-keys vi
# These don't work without an included color scheme. Meh.
# set-option -g status-left "[#[fg=cyan]#S#[default]]"
# set-option -g status-left-length 20
set-option -g status-right "[#h] %F %R %z"
set-option -g visual-activity on
set-window-option -g monitor-activity on
set-window-option -g window-status-current-format '{#I.#P:#W#F}'
set-option -ga update-environment " COLORFGBG \
SSH_AUTH_SOCK"
# Tmux + Vim shared navigation:
# https://github.com/christoomey/vim-tmux-navigaton
is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
| grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"
bind-key -n 'C-h' if-shell "$is_vim" 'send-keys C-h' 'select-pane -L'
bind-key -n 'C-j' if-shell "$is_vim" 'send-keys C-j' 'select-pane -D'
bind-key -n 'C-k' if-shell "$is_vim" 'send-keys C-k' 'select-pane -U'
bind-key -n 'C-l' if-shell "$is_vim" 'send-keys C-l' 'select-pane -R'
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-shell \"$is_vim\" 'send-keys C-\\' 'select-pane -l'"
if-shell -b '[ "$(echo "$tmux_version >= 3.0" | bc)" = 1 ]' \
"bind-key -n 'C-\\' if-shell \"$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
# This doesn't work well on WSL
# set -g default-terminal "tmux-256color"