xclip processes run through tmux bindings never end

20 views
Skip to first unread message

Kaushal Modi

unread,
Jul 28, 2020, 1:00:05 PM7/28/20
to tmux-users
Hello,

I have been having this in my tmux config for many years and it worked fine, until recently (past few months).

=====
set -g set-clipboard off # default is on

# Copy tmux buffer to primary and clipboard selections
# run -b runs a shell command in background
# http://grota.github.io/blog/2012/05/08/tmux-clipboard-integration/
bind C-w run -b "tmux show-buffer | xclip -i -sel pri && tmux show-buffer | xclip -i -sel cli"

# Paste into tmux; also replace LF characters with
# space as separator characters (-s) when pasting.
# Yank from primary
bind C-y run -b "xclip -o -sel pri | tmux load-buffer - && tmux paste-buffer -s ' '"
=====

I just realized that the xclip processes created using these bindings never get killed. Once a certain number of xclip processes are running in parallel, copy/pasting in tmux using the above bindings stops working.

Has there been a change in tmux 3+ that could affect this? I don't recall having to kill stray xclip processes in the last tmux 2.x version.

--
Kaushal Modi

Nicholas Marriott

unread,
Jul 28, 2020, 1:06:53 PM7/28/20
to Kaushal Modi, tmux-users
xclip always stays in the background because it has to own the clipboard, it isn't up to tmux to kill it, it should exit when a new xclip comes along. 




--
You received this message because you are subscribed to the Google Groups "tmux-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tmux-users+...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/tmux-users/CAFyQvY0LcvEWcshNM1-Px6kRus6MnzBneu%3D_grK-7_mVeCmYNA%40mail.gmail.com.

Kaushal Modi

unread,
Jul 28, 2020, 1:14:46 PM7/28/20
to Nicholas Marriott, tmux-users
Hello Nicholas,

Thanks for your quick reply.

Though, has something then been fixed in tmux that doesn't kill xclip any more?

--
Kaushal Modi

Suraj N. Kurapati

unread,
Jul 28, 2020, 2:08:58 PM7/28/20
to Kaushal Modi, tmux-users
Hi,

On Tue, 28 Jul 2020 12:59:27 -0400, Kaushal Modi wrote:
> set -g set-clipboard off # default is on

If your terminal supports OSC-52 escape sequences, you can leave this
setting at its default value and have tmux's copy-mode selections and
mouse selections go directly to your clipboard (without the need for
intermediary tools like xclip and their X11-forwarding requirements).

By default, tmux writes to X11's primary selection, but you can tell it
to instead write to X11's clipboard selection using a terminal-override:

# yank to system clipboard rather than primary selection
# http://invisible-island.net/xterm/terminfo-contents.html#tic-xterm_tmux
set-option -ga terminal-overrides ',xterm*:Ms=\E]52;c;%p2%s\007'

Another advantage of this approach is that it works over SSH (through
any number of additional SSH sessions nested therein)! See my article
for more information: https://sunaku.github.io/tmux-yank-osc52.html

Cheers.

Nicholas Marriott

unread,
Jul 28, 2020, 2:34:43 PM7/28/20
to Kaushal Modi, tmux-users
Not as far as I remember. Does it help if you redirect xclip stdin to /dev/null?

topcat

unread,
Jul 29, 2020, 3:34:19 PM7/29/20
to tmux-users
When xclip is writing to the clipboard, I redirect its stdout like so:
bind-key C-y run "tmux save-buffer - | xclip -i -selection clipboard > /dev/null"

(for reference I use the following command to paste inside tmux from clipboard: bind-key C-p run "tmux set-buffer \"$(xclip -o -selection clipboard)\"; tmux paste-buffer")

Also, make sure that you are accessing the same X display from different shells. After ssh logoff/logon, the DISPLAY might change. tmux picks this up correctly but already running shells won't.

HTH
Reply all
Reply to author
Forward
0 new messages