aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/%HOME%/.tmux.conf
blob: 3f8bf744c346fa93ff5396b50a292b7c4c87dade (plain) (blame)
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
# [1]: https://wiki.archlinux.org/index.php/tmux
# [2]: https://gist.github.com/Lartza/6a7a62466a8a3e436234412d9b1c5066
# [3]: http://mutelight.org/practical-tmux
# [4]: https://github.com/tmux-plugins/tmux-sensible
# [5]: https://github.com/tmux-plugins/tmux-yank
# [6]: https://github.com/greymd/dotfiles/blob/333c46dab103d4316a83744dec28605dc2cbc4ab/.tmux.conf

# C-b is hella uncomfortable to press.
unbind C-b
set -g prefix C-j
bind -n M-j send-prefix

# Why launch a login shell?
set -g default-command "${SHELL}"

# Numbering starts at 1 instead of 0.
set -g base-index 1
set-window-option -g pane-base-index 1

# I'm not sure about this. Still, it's recommended by tmux-sensible, etc.
set -s escape-time 0

# Enable mouse support. You can now scroll inside panes. It automatically
# enters copy mode though, which you can exit by pressing q. Right click to
# bring up the emulator's context window won't work though, hold Shift for
# that.
set -g mouse on

# Default is only 2000 lines?!
set -g history-limit 50000

# Show tmux messages for a longer time (0.75 seconds is the default).
set -g display-time 4000

# Refresh the status line more often (every 15 second is the default).
set -g status-interval 5

# The following settings I don't totally understand/need, but they looked
# sensible enough, and they were recommended at least somewhere.

set-window-option -g monitor-activity on
set -g visual-activity on

set -g focus-events on

set-window-option -g aggressive-resize on

# Key bindings
# ------------

# R to reload this file.
bind R source-file ~/.tmux.conf \; display "Reloaded!"

# According to tmux-sensible, it's more natural to use default readline-like
# key bindings in the command prompt; I sorta agree.
set -g status-keys emacs

# Start new windows/panes in the current directory.
bind c new-window -c "#{pane_current_path}"
# The defaults for pane splitting are the dumbest bindings I've ever seen.
bind - split-window -v -c "#{pane_current_path}"
bind v split-window -h -c "#{pane_current_path}"

# Switch between panes quicker.
bind -n M-1 select-pane -t 1
bind -n M-2 select-pane -t 2
bind -n M-3 select-pane -t 3
bind -n M-4 select-pane -t 4
bind -n M-5 select-pane -t 5
bind -n M-6 select-pane -t 6
bind -n M-7 select-pane -t 7
bind -n M-8 select-pane -t 8
bind -n M-9 select-pane -t 9
bind -n M-0 select-pane -t 0

bind -r h select-pane -L
bind -r j select-pane -D
bind -r k select-pane -U
bind -r l select-pane -R

# Copy mode bindings
# ------------------

# I looked up useful bindings here[2] and there[5].

# Don't care if $EDITOR is not set up, I'm a vim guy.
set -g mode-keys vi

# This I'm unsure about.
bind Escape copy-mode
# This I'm sure about.
bind-key -T copy-mode-vi v send -X begin-selection

# Using the system clipboard.

# y to copy to the system clipboard.
# Y to immediately insert in the current pane.
# M-y is y and Y combined.
# ! to copy excluding line endings (most useful for one-line selections).

# 1. Cygwin

if-shell 'uname | grep -q -F CYGWIN' {
  bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel 'cat > /dev/clipboard'
  bind-key -T copy-mode-vi Y send-keys -X copy-pipe-and-cancel 'tmux paste-buffer'
  bind-key -T copy-mode-vi M-y send-keys -X copy-pipe-and-cancel 'cat > /dev/clipboard; tmux paste-buffer'
  bind-key -T copy-mode-vi '!' send-keys -X copy-pipe-and-cancel {
    tr -d '\n' > /dev/clipboard
  }
  bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel 'cat > /dev/clipboard'
  bind-key -T root MouseDown2Pane run 'cat /dev/clipboard | tmux load-buffer - && tmux paste-buffer'

  bind-key ] run 'cat /dev/clipboard | tmux load-buffer - && tmux paste-buffer'
}

# 2. Linux

# Depends on xsel.
# The simple `xsel -i --clipboard` doesn't work, but `xsel -i -p && xsel -o -p
# | xsel -i -b` [1] does. How fun!

if-shell 'uname | grep -q -F Linux && which xsel' {
  bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel 'xsel -i -p && xsel -o -p | xsel -i -b'
  bind-key -T copy-mode-vi Y send-keys -X copy-pipe-and-cancel 'tmux paste-buffer'
  bind-key -T copy-mode-vi M-y send-keys -X copy-pipe-and-cancel 'xsel -i -p && xsel -o -p | xsel -i -b; tmux paste-buffer'
  bind-key -T copy-mode-vi '!' send-keys -X copy-pipe-and-cancel {
    tr -d '\n' | xsel -i -p && xsel -o -p | xsel -i -b
  }
  bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel 'xsel -i -p && xsel -o -p | xsel -i -b'
  bind-key -T root MouseDown2Pane run 'xsel -o | tmux load-buffer - && tmux paste-buffer'

  bind-key ] run 'xsel -o | tmux load-buffer - && tmux paste-buffer'
}

# Appearance
# ----------

# Highlight active window panes/windows, might not work so well depending on
# your color scheme.
set-window-option -g window-status-current-style bg=red
set-window-option -g window-style bg=#000000
set-window-option -g window-active-style bg=#181818