Questions tagged [xclip]

xclip is a command line interface to the X11 clipboard.

xclip
Filter by
Sorted by
Tagged with
0 votes
0 answers
28 views

How to detect selected text from a PDF using Python in a Django application?

I have a Python script that successfully detects selected text from a PDF file using the xdotool and pyperclip libraries. Here's the script: import time import os import subprocess import pyperclip ...
-2 votes
6 answers
86 views

Bash Script for Copying to Clipboard

My goal is to write an alias to copy the current command and its output to the clipboard, e.g.: ls | myclip This should result in the following being in the clipboard: $ ls Desktop Documents ...
7 votes
3 answers
1k views

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 ...
43 votes
3 answers
19k views

How to make xclip strip newline from the output piped to it?

this is the command responsible for adding a new line to the string echo "string" | xclip -selection clipboard
0 votes
0 answers
17 views

Is there an xclip equivalent to interact with gpm's paste buffer?

I'm looking for a way to read/write accessing the paste buffer (referred to as "selection" in the manpage) of gpm from commandline, along the lines of how X clipboards can be accessed via ...
0 votes
1 answer
72 views

Emacs shell-command with xclip hangs when copying to clipboard

I'm encountering an issue where running xclip through shell-command in Emacs to copy text to the clipboard hangs. Here's the minimal code snippet that reproduces the problem: (shell-command "echo ...
1 vote
1 answer
639 views

Is there anyway to fix the xclip relate with neovim "+y?clipboard: error: Error: target STRING not available

When use neovim to copy content to system clipboard with "+y way. It works well if neovim's window doesn't close, if I close neovim window, the content of + register will disappear. for example, ...
1 vote
1 answer
745 views

Docker container - yank text using xclip

I am having issues related with xclip in a docker container. echo "text" | xclip which raises the error: Error: Can't open display: (null). How can I programmatically add some text to host'...
0 votes
0 answers
33 views

Sublime text 4 plugin development: memory copy problem

I am creating a plugin for sublime 4 on Ubuntu 22.04. The plugin uses pyclip (https://pypi.org/project/pyclip/) to copy text from the "clipboard" and perform certain formatting functions on ...
8 votes
2 answers
2k views

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 ...
2 votes
2 answers
859 views

node child_process execSync hangs with xclip

I'm trying to use child_process to execute xclip -selection c, but it seems to hang or significantly delay execution. I've tried using execSync, require('child_process').execSync('echo hi | xclip -...
0 votes
0 answers
81 views

Why can't I paste using python3 pyperclip in Debian 12?

In Chapter 6 of Automate the Boring Stuff with Python (by Sweigart) the following example usage of pyperclip is given for copying 'Hello, world'! to the clipboard. However when pressing Ctrl + V in a ...
7 votes
4 answers
9k views

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?
1 vote
0 answers
86 views

cant change keyboard layout with xdotool

trying to get the current string written in the search bar in Firefox to be copied to my clipboard, than translating it like it was written in Hebrew keyboard layout, than pasting the translated ...
3 votes
2 answers
915 views

xclip and trailing spaces

I use xclip to get my current path in my clipboard this way : pwd | xclip -selection c it almost works : if you paste (ctrl v) in an empty file, you will see that there is a trailing carriage return....
4 votes
0 answers
183 views

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 ...
6 votes
2 answers
2k views

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 ...
3 votes
1 answer
2k views

ubuntu 20.04 xclip targets has not image types

Currently I am not able to copy/paster images in gnome, especially for screenshots. When take a screenshot and save to clipboard using keyboard short cuts Ctrl+Alt+PrintScreen, an error message output ...
10 votes
1 answer
5k views

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 - ...
3 votes
1 answer
1k views

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 ...
2 votes
1 answer
1k views

Copy and paste svg image to libreoffice writer using xclip

I am used to use xclip to copy/paste png files into libreoffice writer. The command I use is: xclip -selection clipboard -t "image/png" -i <path_to_file> Now, I want to copy/paste svg images, ...
0 votes
0 answers
120 views

xclip not getting stdin from pexpect, or pexpect not sending?

This import pexpect def run(cmd, stdin): child = pexpect.spawn(cmd, encoding='utf-8') child.send(stdin) child.sendeof() run('xclip -selection clipboard', 'lol') should copy string lol ...
0 votes
1 answer
285 views

Programmatically Executing Clipboard Contents within Bash Shell (or Better Approach)

I'm currently working on a bash script which will send the current timestamp and the IP of a system (running Ubuntu 18.04 LTS) to a Slack channel using a webhook as shown below: ##!/bin/bash command=(...
0 votes
0 answers
60 views

Fish shell function behave differently when called using $TERM -e

I have the following fish function, that passes a list of words to fzf and once I select one, it removes the line break from the end and send it to the clipboard. function spell_checker fzf < /...
1 vote
1 answer
5k views

How can I copy the contents of a file directly into my Windows clipboard when I'm running the command on a remote Linux machine via ssh in Git Bash?

I'm using Windows 10. I open Git Bash and then ssh into an Ubuntu server. Often I want to copy the whole contents of a large text file. Rather than using scp to download the file to my Windows ...
3 votes
1 answer
408 views

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 ...
1 vote
2 answers
322 views

Create a shortcut for a string that goes through a program

I have to, a lot of times, get things onto the clipboard from the terminal. I do it like this: echo "something"|xclip -selection clipboard Doing this every time is way too lame, and I want to make a ...
2 votes
1 answer
536 views

Accessing clipboard on Travis-CI

I am trying to run an (integration?) test on my application, to verify that it actually copies the expected string to the clipboard with pyperclip. This part is working on my development machine (...
-1 votes
1 answer
1k views

How to copy on xclip and see the command output on the shell?

Whenever I use xclip the command output goes right the clipboard but I also need to see it on the terminal: I already tried this commands using pipe and & |&: pwd |& xclip -rmlastnl -...
0 votes
0 answers
320 views

KDE Custom shortcut to re-implementing copy paste (could DBus work ?)

I'm on KDE in french and I use the Raccourcis Personalisés menu to create custom keyboard shortcuts, I would like ⊞ Windows+C and ⊞ Windows+V to be copy (bash xclip -selection clipboard) and paste (...
1 vote
0 answers
74 views

How to run selected text using keyboard shortcut joined together with a command in background?

I am trying to be able to select text anywhere within my manjaro linux system and run it along with a TTS text to speech program. The program is called google_speech and it got a really clear default ...
5 votes
3 answers
4k views

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 ...
5 votes
2 answers
1k views

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 ...
3 votes
1 answer
399 views

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("...
2 votes
0 answers
554 views

xclip gtk copy file

While trying to copy files into the clipboard through bash, I ran into a bit of trouble. I'm currently using 'xclip -i -selection clipboard -t text/uri-list <<< $1' . The script works as ...
5 votes
1 answer
1k views

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: ...
3 votes
1 answer
1k views

Bash - change text copied to the clipboard using xclip

I am trying to convert text copied to the clipboard from something like this: +50.8863-114.0157/ to something like this: geo:50.8927777778,-114.013055556,0 I found this code on the Web: #!/bin/...
0 votes
1 answer
271 views

Code in Shell Script runs before other Operations

This same problem is better formulated in a question posted to the Unix & Linux StackExchange community. I am programming a script which opens on a key press, open a new terminal (gnome-terminal),...
1 vote
1 answer
929 views

xclip check if "selection" is empty

As an FYI this is on Linux. I want to have one of the options in a script to be to pull the selected text. So I start my script #!/bin/bash xclip -o > ~/bin/temp.txt However, if I don't have ...
9 votes
1 answer
12k views

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:...
0 votes
1 answer
2k views

How to copy output of command line from remote, to local clipboard via ssh

I am using HPC on campus and it is CentOS. I asked administrator to install xclip in HCP. But he said it would endanger to HPC. I am not root user. I am wondering whether there is a way to I can copy ...
2 votes
1 answer
864 views

Why has xclip -loop 1 stopped working?

If I use e.g. echo 'test' | xclip -i -selection primary -loops 1 -quiet and paste into another terminal window, it works as expected, i.e. 'test' is pasted and then the primary selection goes back ...
2 votes
2 answers
398 views

Git pre-push hook hangs after piping to xclip

Preamble: When committing I tend to format message as following: [<task number>] <task title> which should be converted by pre-push hook to a valid GitHub syntax as following: Work ...
1 vote
1 answer
448 views

Vim, yanking with xclip, getting rid of escape characters

I am using vim to edit files on several systems through ssh, some of which have or do not have -clipboard option compiled in. Therefore I have been trying to use xclip to copy some parts of the text ...
0 votes
2 answers
612 views

when linux system calls scripts some commands don't work ( cron / if-up.d )

Hi I'm trying to run a script that calls xclip in order to have a string ready to paste when i connect to the internet. I have a script /etc/network/if-up.d/script that does execute when connecting (...
1 vote
1 answer
264 views

Sending Strings Queue to Clipboard in python

I am writing a program that runs in background and check's for file changes in a folder if any new Image file arrives into that folder it will read text from that Image with the help of tesseract OCR ...
3 votes
2 answers
528 views

Why `xclip .bashrc` takes much longer than system("xclip .bashrc") in ruby?

irb(main):001:0> require 'benchmark' => true irb(main):002:0> puts Benchmark.measure { system "xclip .bashrc" } 0.000000 0.000000 0.000000 ( 0.008030) => nil irb(main):003:0> ...
1 vote
2 answers
670 views

Unexpected EOF in .bashrc alias

I am getting an unexpected end of file error after including this line in my .bashrc alias domsrv01='echo -e ?HT_R8\'% | xclip ; ssh 10.50.0.35' The desired exit from echo to xclip is: ?HT_R8'% ...
12 votes
1 answer
2k views

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 ...
3 votes
0 answers
325 views

Subprocess.check_output or xclip -o hanging

On Linux mint I'm using the following code to monitor my clipboard: last_clip = '' try: while True: clip_contents = subprocess.check_output(['xclip', '-o']) if clip_contents != ...