-
Notifications
You must be signed in to change notification settings - Fork 0
/
.tmux.conf
110 lines (91 loc) · 4.35 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
# previously, this was "xterm-256color", but when using the pager, mutt would
# not completely clear the screen when you selected a different message,
# leaving traces of the previous one
# the change is in line with the tmux FAQ that strongly suggests to use
# something similar to "screen"
# https://raw.githubusercontent.com/tmux/tmux/master/FAQ
set -g default-terminal "screen-256color"
# recommended by `:checkhealth nvim`
set-option -a terminal-features 'screen-256color:RGB'
# http://superuser.com/a/217269
# for using the mouse wheel to scroll
# http://stackoverflow.com/a/31612577
# for the deprecation of `mode-mouse`
set-window-option -g mouse on
# https://github.com/tmux-plugins/vim-tmux-focus-events#tmux-configuration
set-window-option -g focus-events on
# forward "window title" to terminal emulator
# https://superuser.com/a/1098626
set-window-option -g set-titles on
set-window-option -g set-titles-string "#S / #W"
# https://github.com/edkolev/tmuxline.vim#usage
# for using vim’s colors in tmux’ statusline
source-file "$HOME/.tmuxline.conf"
# switch pane in tmux or send C-h, C-j, C-k, C-l to vim which triggers split
# switching in vim
# https://github.com/christoomey/vim-tmux-navigator
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"
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 -n F3 previous-window
bind-key -n F4 next-window
# http://www.johnhawthorn.com/2012/09/vi-escape-delays/
# http://unix.stackexchange.com/a/25638
# http://superuser.com/a/252717
# to make vim go out of insert mode without delay on pressing <Esc>
set -sg escape-time 0
# when using the layout `main-horizontal`, the top pane should be larger than
# the bottom one
set-window-option -g main-pane-height 42
set-window-option -g base-index 1
# shortcuts that show a menu for selecting the target window when moving panes
# http://superuser.com/questions/600286/tmux-move-pane-to-new-window
bind-key S choose-window "join-pane -v -t "%%""
bind-key V choose-window "join-pane -h -t "%%""
# https://robots.thoughtbot.com/tmux-copy-paste-on-os-x-a-better-future
# https://coderwall.com/p/4b0d0a/how-to-copy-and-paste-with-tmux-on-ubuntu
# use vim keybindings in copy mode
set-window-option -g mode-keys vi
# Tmux 2.4 changed the way copy mode keys are configured. The following
# configuration works on Tmux >= 2.4.
#
# https://github.com/tmux/tmux/blob/641a885af81c3dd16f72afc2122b8a4945d61e0f/CHANGES#L230
# https://github.com/tmux/tmux/commit/76d6d3641f271be1756e41494960d96714e7ee58
# https://github.com/tmux/tmux/issues/754
#
# use v to begin selection
bind-key -T copy-mode-vi v send-keys -X begin-selection
# use y to copy the selection, but not leave copy mode
bind-key -T copy-mode-vi y send-keys -X copy-pipe "xclip -sel clip -i"
# use Enter (defaults to copying to tmux’ paste buffer) to copy the selection
# and leave copy mode
unbind -T copy-mode-vi Enter
bind-key -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel "xclip -sel clip -i"
# https://github.com/tmux/tmux/issues/140#issuecomment-321144647
# don’t leave copy mode when a mouse drag is finished
unbind -T copy-mode-vi MouseDragEnd1Pane
# open new windows/splits in current path
# https://unix.stackexchange.com/questions/12032/create-new-window-with-current-directory-in-tmux
bind-key c new-window -c "#{pane_current_path}"
bind-key '"' split-window -c "#{pane_current_path}"
bind-key % split-window -h -c "#{pane_current_path}"
# start fish as non-login shell
# https://wiki.archlinux.org/index.php/tmux#Start_a_non-login_shell
# see `man tmux` on `default-command`
#
# for the rationale on why tmux starts a login shell by default, see
# https://superuser.com/a/970847
set -g default-command "/usr/bin/fish"
# `<prefix> I` installs the plugins specified below
# https://github.com/tmux-plugins/tpm
set -g @plugin 'tmux-plugins/tpm'
# https://github.com/tmux-plugins/tmux-urlview#dependencies
set -g @plugin 'tmux-plugins/tmux-urlview'
run "$HOME/.tmux/plugins/tpm/tpm"