3

I've noticed tmux copy-pipe truncating selection (leaving out the last part of the selection).

Eg:

bind-key -T copy-mode-vi y send-keys -X copy-pipe "xclip -in -sel clipboard"

Sometimes only copies the first few 100 bytes into the buffer.

I don't think this is an issue with xclip since this happens with xsel too.

For some reason piping into a file, sleeping, then passing to xclip works.

bind-key -T copy-mode-vi y \
  send-keys -X copy-pipe "cat > /tmp/tmux_clip.txt" \; \
  run "sleep 0.1" \; \
  run -b "xclip -in -sel clipboard /tmp/tmux_clip.txt > /dev/null" \; \
  display "Clipboard Copy"

Is this a known issue? are there ways to resolve this?

  • This seems to be a new occurrence, as it used to work just fine. Happening now for me too though. You can sort of work around it with tmux show-buffer | xsel -ib, but it's not ideal. – Jon Gjengset Apr 20 '18 at 16:32
1

If you have the set-clipboard option set to on or external (default) and your terminal support OSC 52 then copy-pipe will also send the copied data to your tty using an xterm escape sequence to set the selection. tmux correctly sends the whole copied text, but your terminal may have a limited-size buffer to receive the data. This is mentioned on tmux#1119.

It may work sometimes because the call to xclip is put in the background and may finish after the built-in clipboard setting operation. Additionally, this may have started happening recently if you updated your terminal and it implemented OSC 52 support (e.g. alacritty).

Your options are:

  • Add set-option -g set-clipboard off to your tmux config
  • set a higher buffer size limit in your terminal if possible (or file an issue) and ditch copy-pipe entirely

keywords: tmux clipboard truncated, tmux doesn't copy all characters, tmux copy truncated

0

I have started seeing the same issue, but don't have a good explanation for why. However, the proposed tmux >= 2.5 solution over at https://unix.stackexchange.com/a/131187/44909 fixes the issue for me. Specifically, make your .tmux.conf have:

bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel 'xclip -in -selection clipboard'

The -and-cancel bit seems to be what does it. If I just use copy-pipe it does not work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.