aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/%HOME%/.tmux.conf
blob: d9d05d4ece2e55d823900bdd0eba6ce94c3be5ff (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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
# [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

# The default seems to be "screen" on my machine, and if I ssh to a remote
# system, all the 256 colors might not be supported. Check using this script:
# https://superuser.com/a/285400. I'm eager to see what kinds of trouble it
# will bring me.
set -g default-terminal "screen-256color"

# 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 -g focus-events on

set-window-option -g aggressive-resize on

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

# X to kill the current session.
bind X confirm-before kill-session
# A to kill all but the current session.
bind A confirm-before 'kill-session -a'

# 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
# ----------

set -g status-right "%d %b %H:%M"

# Might not work so well depending on your color scheme.

set -g status-style fg=white,bg=blue
set-window-option -g window-status-current-style fg=black,bg=white
#set-window-option -g window-status-current-style fg=terminal,bg=colour234

set-window-option -g pane-border-style fg=colour248,bg=colour232
set-window-option -g pane-active-border-style fg=colour248,bg=colour234

set-window-option -g window-style bg=colour232
set-window-option -g window-active-style bg=colour234