-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathtmux.conf
135 lines (112 loc) · 4.72 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
# NOTE to self:
# - change split, use C-a option-[1-5]
# SEE:
# https://superuser.com/questions/493048/how-to-convert-2-horizontal-panes-to-vertical-panes-in-tmux
# colors-option
set -g default-terminal "screen-256color"
#set inactive/active window styles
set -g window-style 'bg=colour235'
set -g window-active-style 'bg=colour234'
# https://github.com/dandavison/delta/pull/1560/files
set -ga terminal-overrides ",*-256color:Tc"
# remap prefix to Control + a
set -g prefix C-a
unbind C-b
# bind C-a send-prefix
bind a send-prefix
# make tmux a bit more like screen
# http://stackoverflow.com/questions/7771557/how-to-terminate-a-window-in-tmux
bind x kill-window
# bind x confirm kill-window
bind q last-window
bind-key m resize-pane -Z
# prevent confirmation for pane killing
bind k kill-pane
# force a reload of the config file
unbind r
bind r source-file ~/.tmux.conf
# bind fast session switching
unbind S
bind S command-prompt "switch -t %1"
# quick pane cycling
unbind ^A
bind ^A select-pane -t :.+
# rebind pane tiling
bind | split-window -h -c "#{pane_current_path}"
bind - split-window -v -c "#{pane_current_path}"
bind V split-window -h -c "#{pane_current_path}"
bind S split-window -v -c "#{pane_current_path}"
# start window numbering at 1 for easier switching
set -g base-index 1
# vim movement bindings
set-window-option -g mode-keys vi
bind-key -Tcopy-mode-vi 'v' send -X begin-selection
bind-key -Tcopy-mode-vi 'y' send -X copy-pipe-and-cancel "reattach-to-user-namespace pbcopy"
# remote version of copy
bind-key -T copy-mode-vi 'Y' send-keys -X copy-pipe-and-cancel "tmux save-buffer /tmp/tmux-copy.txt" \; run "remote copy command"
# NOTE: or just use this on linux?
# bind-key -Tcopy-mode-vi 'y' send -X copy-selection
bind-key -Tcopy-mode-vi Escape send -X cancel
bind-key -Tcopy-mode-vi V send -X rectangle-toggle
# SEE: https://blog.bugsnag.com/tmux-and-vim/
# and https://github.com/christoomey/vim-tmux-navigator
# -t version stopped working https://github.com/christoomey/vim-tmux-navigator/issues/299
# is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
# | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"
is_vim="ps -o state=,tty=,comm= | grep -iqE '^[^TXZ ]+ +#{s|/dev/||:pane_tty}\s+(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"
# is_fzf="ps -o state= -o comm= -t '#{pane_tty}' \
# | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?fzf$'"
is_fzf="ps -o state=,tty=,comm= | grep -iqE '^[^TXZ ]+ +#{s|/dev/||:pane_tty}\s+(\\S+\\/)?fzf$'"
bind -n C-h run "($is_vim && tmux send-keys C-h) || \
tmux select-pane -L"
bind -n C-j run "($is_vim && tmux send-keys C-j) || \
($is_fzf && tmux send-keys C-j) || \
tmux select-pane -D"
bind -n C-k run "($is_vim && tmux send-keys C-k) || \
($is_fzf && tmux send-keys C-k) || \
tmux select-pane -U"
bind -n C-l run "($is_vim && tmux send-keys C-l) || \
tmux select-pane -R"
# TODO: C-; instead?
bind -n 'C-\' if-shell "$is_vim" "send-keys 'C-\\'" "select-pane -l"
# unicode
# setw -g utf8 on
# set -g status-utf8 on
# status bar config
# status bar colors
set -g status-bg black
set -g status-fg white
# alignment settings
set-option -g status-justify centre
# status left options
set-option -g status-left '#[fg=green][#[bg=black,fg=cyan]#S#[fg=green]]'
set-option -g status-left-length 20
# window list options
set-window-option -g automatic-rename off
set-window-option -g window-status-format '#[fg=cyan,dim]#I#[fg=blue]:#[default]#W#[fg=grey,dim]#F'
set-window-option -g window-status-current-format '#[bg=black,fg=cyan,bold]#I#[bg=black,fg=cyan]:#[fg=colour230]#W#[fg=dim]#F'
set -g base-index 1
# listen to alerts from all windows
set -g bell-action any
# make history limit larger
set-option -g history-limit 100000
# SEE: http://stackoverflow.com/questions/11832199/tmux-set-g-mouse-mode-on-doesnt-work
# let mouse do stuff
set -g mouse on
# make scrolling with wheels work
bind -n WheelUpPane if-shell -F -t = "#{mouse_any_flag}" "send-keys -M" "if -Ft= '#{pane_in_mode}' 'send-keys -M' 'select-pane -t=; copy-mode -e; send-keys -M'"
bind -n WheelDownPane select-pane -t= \; send-keys -M
# don't make escape pause
# SEE: https://bitbucket.org/lyro/evil/issues/69/delay-between-esc-or-c-and-modeswitch
set -s escape-time 0
# Update environment variables for tmux when reattaching
# SEE: https://babushk.in/posts/renew-environment-tmux.html
set-option -g update-environment "SSH_AUTH_SOCK \
SSH_CONNECTION \
DISPLAY"
# TODO OSX copying doesn't work
# try this? https://evertpot.com/osx-tmux-vim-copy-paste-clipboard/
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