dotfiles

$HOME is where the <3 is
git clone git://git.alexkarle.com/dotfiles.git
Log | Files | Refs | Submodules | README

commit ddecb7914bcd8cc5f2a4d6809fea748c83da3f3b (patch)
parent 7a0e754ccd33f21f97a0b7fd70e3474544ac5e53
Author: Alex Karle <alex@karle.co>
Date:   Wed, 19 Jun 2019 23:41:12 -0400

[tmux] pipe copy-selection to xclip for copying

After noticing strange behavior in tmux with copy/pasting, I found the
root issue (described in github issue tmux#1119):

set clipboard on (the default) will try to set the system clipboard by
sending it an escape sequence. The terminal emulator I am currently
using (st) *can* handle this escape sequence, but the buffer size it has
for it is abysmally small (1024 chars).

Thankfully, the workaround is rather simple: disable this escape
sequence sending (to avoid a race condition with xclip) and change
the binding of 'y' in copy-mode-vi to pipe to xclip instead (which can
handle a much larger buffer).

This will obviously not hold up on macOS, but for now I am working only
on Linux so this isn't a big issue.

Diffstat:
Mtmux/tmux.conf | 11++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/tmux/tmux.conf b/tmux/tmux.conf @@ -1,7 +1,7 @@ # remap prefix from 'C-b' to 'C-a' unbind C-b set-option -g prefix C-a -bind-key C-a send-prefix +bind C-a send-prefix # split panes using | and - bind | split-window -h -c "#{pane_current_path}" @@ -29,8 +29,13 @@ bind C-l select-pane -R # set vi-bindings for scrolling set-window-option -g mode-keys vi -bind-key -T copy-mode-vi 'v' send -X begin-selection -bind-key -T copy-mode-vi 'y' send -X copy-selection-and-cancel +bind -T copy-mode-vi v send -X begin-selection +bind -T copy-mode-vi y send -X copy-pipe-and-cancel 'xclip -in -selection clipboard' + +# st can't handle a large clipboard. Setting clipboard off causes the above +# pipe to xclip to take precedence: +# https://github.com/tmux/tmux/issues/1119 +set -g set-clipboard off # Set mouse on for scrolling / pane selection and resizing set -g mouse on