xclip is a command line interface to the X11 clipboard.
Questions tagged [xclip]
46 questions
41
votes
3 answers
echo "string" | xclip -selection clipboard , copies the 'string' but also adds a new line to it. how to fix this?
this is the command responsible for adding a new line to the string
echo "string" | xclip -selection clipboard
user2453554
12
votes
1 answer
Bash command substitution ( $(...) ) forcing process to foreground
Summary: I have a bash script that runs a process in background, and is supposed to work as a normal command and inside a command substitution block such as $(...). The script itself spawns a process that forks to background. It can be reduced to…

dequis
- 2,100
- 19
- 25
9
votes
1 answer
xclip and xsel - FileNotFoundError: [Errno 2]
I have kivy 1.10.1, python 3.8.2 and I code on Ubuntu20.04.
When I launch my little program, I receive this error:
[CRITICAL] [Cutbuffer ] Unable to find any valuable Cutbuffer provider.
xclip - FileNotFoundError: [Errno 2] Aucun fichier ou…

Snakiron
- 423
- 4
- 11
9
votes
1 answer
xclip gives `Error: Can't open display: localhost:10.0` in tmux session in Ubuntu VirtualBox VM
I'm attempting to use xclip in a tmux session in my Ubuntu VirtualBox VM for some copy/paste keybindings, but keep getting the same error message.
I have XQuartz installed on my host machine:
ysim:~$ which xquartz
/opt/X11/bin/xquartz
ysim:~$ echo…

3cheesewheel
- 9,133
- 9
- 39
- 59
8
votes
1 answer
xclip does not terminate when tracing it
I have made the following observations:
$ xclip text.txt
The execution terminates instantly, it copies the content of text.txt to the default selection XA_PRIMARY which means you can paste it through your middle mouse button or xclip -o.
When I…

Konrad Reiche
- 27,743
- 15
- 106
- 143
7
votes
2 answers
Copying a non PNG image to the X clipboard
Several questions have already been answered regarding copying images to the X clipboard, and the answer is always to use xclip like so:
xclip -selection clipboard -t image/png -i image.png
This works, but only for PNG files. You might imagine that…

Sr. Komodo
- 163
- 1
- 4
7
votes
4 answers
Paste clipboard content into a variable in bash using xclip
I know this command will paste the clipboard contents into a file:
xclip -out -selection clipboard >> file.txt
If I want to paste clipboard content into a variable like a string what do I do?

Do Thanh Tung
- 1,223
- 2
- 19
- 30
6
votes
2 answers
Avoid "enter" when pasting xsel / xclip
This is somewhat simple, I presume, but still I cannot figure out how to do it. I have the following function defined:
date +%Y-%m-%d_%H:%M | xclip -selection c
which gets a timestamp and puts it into the clipboard. I mainly want to use this to…

TomCho
- 3,204
- 6
- 32
- 83
5
votes
3 answers
How to clear both clipboards securely in Gnome, from Python?
Gnome desktop has 2 clipboards, the X.org (saves every selection) and the legacy one (CTRL+C). I am writing a simple python script to clear both clipboards, securely preferably, since it may be done after copy-pasting a password.
The code that I…

Markus84612
- 191
- 1
- 3
- 11
5
votes
1 answer
Python script using subprocess and xclip hangs if piped in bash
I have a python script that needs to output some values to stdin and copies another string to clipboard. I'm using the module subprocess to execute the xclip utility through Popen something like this:
# clip.py
import subprocess
from subprocess…

mglart
- 360
- 3
- 11
5
votes
2 answers
Keyboard shortcuts in Tmux deactivated after using xclip
I am using the following configuration in my .tmux.conf to copy text to-and fro from xclip
bind C-c run "tmux save-buffer - | xclip -i -sel clipboard"
bind C-v run "tmux set-buffer \"$(xclip -o -sel clipboard)\"; tmux paste-buffer"
If I run…

RAbraham
- 5,956
- 8
- 45
- 80
4
votes
0 answers
Byobu with screen backend: Connect copy buffer to system clipboard
I'm using Byobu with the screen backend. (Because the default tmux backend causes some bug in SSH.)
When I use Byobu's copy feature to mark text with the keyboard and copy it into the buffer, I want that text to be copied to the system clipboard, so…

Ram Rachum
- 84,019
- 84
- 236
- 374
3
votes
1 answer
Output redirection hangs if process has spawned a background fork of xclip
I've got a script which calls to xclip inside. Something like this:
#!/bin/bash
RESULT="some data"
echo $RESULT | xclip
echo $RESULT
xclip puts puts the data from its stdin to the clipboard, spawns a background thread to preserve that buffer…

Denis Sheremet
- 2,453
- 2
- 18
- 34
3
votes
1 answer
How do I copy a PIL picture to clipboard
I'm working with a canvas in Tkinter, and I'm trying to copy the contents of that canvas to the clipboard.
I am able to solve this by creating a file, and then copy the content of that file into the clipboard with xclip -selection clipboard -t…

mazunki
- 682
- 5
- 17
3
votes
1 answer
xclip from non-bash shell not enduring
In bash, echo toast | xclip -sel c saves the toast inside the clipboard, even when I close the terminal. Why does this seem to be non-persistent from other shells?
python3.5:
import os
os.system("echo toast | xclip -sel c")
Does the job, but when I…

phil294
- 10,038
- 8
- 65
- 98