Questions tagged [xclip]

xclip is a command line interface to the X11 clipboard. It can also be used for copying files, as an alternative to sftp/scp, thus avoiding password prompts when X11 forwarding has already been setup.

Filter by
Sorted by
Tagged with
1 vote
0 answers
24 views

How can read the content of the active window?

I am trying to create a bash script that selects the content of the active window, copies the content to the clipboard, and saves the content to a file. This file then gets read by some text editor, ...
user avatar
0 votes
0 answers
20 views

xclip doesn't modify clipboards of VMware guest

I have a Linux VMware guest with open-vm-tools installed. As expected, when I select and copy text from the host's xfce4-terminal with Ctrl+Shift+C¸ I can paste this text in the guest via xclip -out. ...
user avatar
  • 24.6k
0 votes
2 answers
329 views

Why tldr | xclip outputs escape codes looking like timestamp, and how to remove it?

Problem I want to copy the output of tldr to clipboard, and then paste that to text editor. I execute: tldr pwd | xclip -sel clip When I paste from clipboard, I get: pwd [0mPrint name of current/...
user avatar
  • 357
1 vote
1 answer
152 views

How to persist the contents of the X11 (copy) clipboard on closing e.g. Vim to paste its contents later?

If I copy to X11 (copy) clipboard in Vim using "+y, I can only paste contents as long as Vim is open. The reason is as follows: From Ubuntu Wiki: ClipboardPersistence: The problem happens ...
user avatar
  • 3,277
2 votes
2 answers
326 views

Linux clipboards, including with WSL consoles

It occurred to me that there are multiple clipboards on any given Linux console: First is the bash clipboard, this can be invoked by Ctrl-U / K, cut all line before (U) or after (K) cursor into ...
user avatar
  • 559
0 votes
0 answers
75 views

Ctrl-D doesn't close the terminal inside VIM after piping the output of cat to clipboard (needs :q)

It's a very specific problem, so I'll try to provide everything that I think might be relevant. I have these two aliases in my ~/.zshrc for copying and pasting the output of commands: $ grep xclip ~/....
user avatar
0 votes
1 answer
145 views

how can I "pipe" all of these to xclip preservering newlines

So, I'm creating this little convenience command for system information when bug reporting. alias clip="xclip -selection clipboard -in" alias bug="echo $(lsb_release -irs && ...
user avatar
0 votes
1 answer
60 views

Setting an alias for copying the current path from shell to clipboard fails [duplicate]

I have added the following alias to my .zshrc: alias pwdc="echo -n $PWD | xclip -selection clipboard" it seems the present working directory is not getting updated, when I move to a ...
user avatar
1 vote
1 answer
2k views

Arch linux: set copy/paste/cut shortcuts

I would like to set custom keyboard shortcuts for using clipboard. I would like to change it from: Copy: ctrl + c in programs, ctrl + shift + c in terminal Paste: ctrl + v in programs, ctrl + shift + ...
user avatar
2 votes
1 answer
425 views

Copy file name without extension in Vifm

From the the Vifm wiki and using xclip, they show how to copy the filename of a selected file: nnoremap yn :!echo -n %c | xclip -selection clipboard %i<cr>:echo expand('%"c') "is ...
user avatar
2 votes
1 answer
330 views

Piping to "xclip" doesn't survive bash script termination

I have an interactive fzf bash script that puts my choice into the X clipboard, like so: #!/bin/bash cat /path/to/file.txt | fzf | xclip -sel p -sel s -sel c exit 0 The text file contains some ...
user avatar
2 votes
0 answers
309 views

xclip to multiple targets

How do I copy different texts to multiple targets using xclip (or other tools)? I tried doing echo "TEST_STRING" | xclip -selection clipboard -t STRING echo "TEST_HTML" | xclip -selection clipboard ...
user avatar
  • 265
2 votes
0 answers
399 views

Copy any kind of file to clipboard with xclip

So, I want to be able to copy any kind of file to an X clipboard with a shell script (mostly as a means to copy files in ranger, to gui applications). So far i have this script: TYPE=$(file -b --mime-...
user avatar
  • 21
0 votes
1 answer
2k views

No package found: install xclip in RHEL 7.6

I am new to the RHEL and want to install xclip package. I have tried yum install xclip It returned no package xclip
user avatar
0 votes
1 answer
102 views

Firefox download file and copy to clipboard

For academic research I work with Firefox and many sites have the option to export entries as Bibtex files which opens a download dialog. I'm looking for a way to directly copy those files to the ...
user avatar
0 votes
1 answer
68 views

Yank trimmed string in tmux copy mode

I am trying to yank string without trailing and heading spaces using this keybinding: bind-key -T copy-mode-vi z send-keys -X \ copy-pipe 'sed "s/^[[:blank:]]\+//;s/[[:blank:]]\+$//" | xsel -ib' ...
user avatar
1 vote
0 answers
451 views

Copy large texts to clipboard in X11

If I try to copy a large file (around 30K) to clipboard with xsel (or xclip), the copy operation fails and the content of clipboard remains unchanged. If it's a hard limit in X11, is there any way to ...
user avatar
  • 1,311
0 votes
1 answer
213 views

How to use existing terminal session to save output with ANSI escape code like `script` or `screen -L` do?

I run a python script on konsole to print long logging for few hours, then I realized I want to save its output with color, but it's too late to run either script or screen -L to save the output as ...
user avatar
  • 4,448
3 votes
1 answer
607 views

Xclip command works in shell but not in keyboard shortcut

I have to paste my email often during the day, and typing it is time consuming. That is why I am searching for a way to do this with a button press. The following command works to place my mail on my ...
user avatar
  • 137
2 votes
1 answer
34 views

Pbcopy acts as Pbpaste when symlinked

To keep my configs sane between environments, I thought it's a great idea to do the following on MacOS. ln -s /usr/bin/pbcopy /usr/local/bin/xclip However, my xclip symlink does not act just as ...
user avatar
1 vote
1 answer
402 views

How to replace CTRL+C shortcut with same action plus xclip save copied selection command?

I am trying to be able to save/log all clipboard selection copies to a clipboard_histroy.log file. I want this to be able to simply append each copied selection to the log file but at the same time ...
user avatar
  • 459
0 votes
2 answers
170 views

How to grab x characters long of start text from xclip selection and append to filename?

So I am trying to figure out how to add a title after the timestamp in my xclip script here. I would like it to grab about 24 characters worth of text from the beginning of each selection and save it ...
user avatar
  • 459
1 vote
1 answer
137 views

How to get clipboard as input file name to Vim on bash?

I install xclip to access system clipboard, my setting and some operations as below: ➜ ~ cat .zshrc | grep xclip alias c="xclip -selection c" alias v="xclip -selection c -o" ➜ ~ which dict | c ➜ ~ ...
user avatar
1 vote
0 answers
139 views

xclip copy file so it can be pasted as a file (not file content) [duplicate]

How can I copy a file with xclip, so that it is pastable as a file in file explorers? I searched on google an so on and found stuff like this Copy file to xclip and paste to Firefox, but there it is ...
user avatar
4 votes
0 answers
597 views

How can I paste a gif from the clipboard with xclip?

I'm trying to copy a gif into my clipboard such that I would be able to paste it into web applications (slack, github, etc.). I have tried the following without any luck: xclip -selection clipboard -...
user avatar
0 votes
2 answers
127 views

xclip doesn’t send contents to netcat

I got an assignment from my teacher to try and beat a bot which sends a number each time and I need to send the exact number, but faster. I wrote a bash script: #!/bin/bash while true; do nc ip ...
user avatar
  • 1
1 vote
0 answers
111 views

Global filter on clipboard?

I'd like to make kind of filter for clipboard to remove newline characters at the end from anything I copy-paste on a daily basis. I know I could set a daemon listening through xclip for changes and ...
user avatar
1 vote
0 answers
165 views

Piping to another program in the middle of a oneliner

I'm trying to create a simple bash one line script that allows me to pick a particular barcode that's visible on my screen and make it available as text on my clipboard. To that effect, I wrote a bash ...
user avatar
  • 131
1 vote
2 answers
339 views

How to chain external commands in VIM?

If I select the following text in a VIM buffer in VISUAL mode f() { echo "f"; } f and then execute :'<,'>w !xclip | !eval "$(xclip -o)" I get /bin/bash: eval: line 3: syntax error ...
user avatar
  • 1,151
4 votes
0 answers
11k views

xclip Outputs "Error: Can't open display: (null)"

I recently installed xclip on my CentOS 7 server. Since my machine does not have an X server, I'd have to configure my machine to forward X11 to my client. Following the steps explained in this ...
user avatar
0 votes
1 answer
588 views

Tmux run-shell xclip not working

I am using tmux 2.3 and want to define a command to send the paste-buffer to system clipboard. I have tried using the command below and every variant I can think of, but when I try to run it, I get a ...
user avatar
6 votes
1 answer
473 views

Why does xclip-copied text pasted into Gmail on Firefox turn line breaks into spaces?

I have a text editor I made that uses xclip to copy text. I notice that when I paste the xclip-copied text (pasting the regular way, with ctrl+v) into a Gmail email on Firefox 54.0 (64-bit) that I'm ...
user avatar
10 votes
2 answers
3k views

xclip image binary contents pasted into text fields

Say I pick some png file and run the following command: xclip -selection clip -t image/png image.png I now have that image in my clipboard. If I paste it somewhere that accepts an image, it is ...
user avatar
1 vote
1 answer
6k views

Copy file to clipboard from console

I'm trying to copy the actual file content, including the file header and binary contents of a file to the clipboard. The file is a .pdf in this case. I've come across multiple solutions, but they ...
user avatar
  • 205
11 votes
2 answers
7k views

How to copy text from command line to clipboard without using the mouse?

I'm trying to figure out a way to copy the current text in a command line to the clipboard WITHOUT touching the mouse. In other words, I need to select the text with the keyboard only. I found a half-...
user avatar
9 votes
0 answers
1k views

xsel and xclip hang

My objective is to make a text on my remote machine (CentOS 7.2) available to seamlessly paste on my local machine (OS X 10.12.2) with the standard ⌘V shortcut. My setup connects to the remote ...
user avatar
  • 221
1 vote
1 answer
1k views

TMUX 2.3 copy to clipboard

I am using TMUX 2.3 just recently copying stopped working. Here is the relevant section that lets me copy stuff to the clipboard: bind-key -t vi-copy 'v' begin-selection bind-key -t vi-copy y copy-...
user avatar
5 votes
3 answers
3k views

xclip works differently in interactive and non-interactive shells

While investigating a problem described in a question at stackoverflow I simplified it down to a test case demonstrating that in non-interactive mode bash seems to clear the X system clipboard before ...
user avatar
  • 181
1 vote
0 answers
59 views

Using xclip as workaround for missing key on keyboard?

My q key is gone from my keyboard. I'm trying to assign ctrl-a as a way to enter my q's, so from the bash prompt echo "q" |xclip; xclip -o outputs a q.. but saving that to a script then ...
user avatar
0 votes
0 answers
823 views

Is the default selection of xclip the primary one?

In the manpage of xclip -selection specify which X selection to use, options are "primary" to use XA_PRIMARY (default), "secondary" for XA_SECONDARY or "clipboard" for XA_CLIPBOARD Since the ...
user avatar
  • 89.7k
-3 votes
1 answer
1k views

Do xsel and xclip work only for copy and not for paste?

The usages of xsel and xclip seem to me all about the copy operation, whether it is primary or clipboard selection. When I perform the paste operation, is it only by using mouse or trackpad, not via ...
user avatar
  • 89.7k
4 votes
1 answer
226 views

Abbreviated long options on the command line of xclip

In the manpage of xclip -selection specify which X selection to use, options are "primary" to use XA_PRIMARY (default), "secondary" for XA_SECONDARY or "clipboard" for XA_CLIPBOARD Note that ...
user avatar
  • 89.7k
11 votes
1 answer
851 views

Is it possible to know the source (application) of the clipboard?

I've noticed that sometimes clipboard contents become unavailable if the source application (where the content was copied from) is closed. This leads me to wonder if it's possible to know what the ...
user avatar
  • 583
2 votes
1 answer
467 views

Is there a way to replace the currently selected text on X11?

I stumbled across xclip which gives you access to the text you have selected on your active window. I've been thinking if there was a way to alter such text. The workflow I have in mind is the ...
user avatar
  • 177
89 votes
9 answers
88k views

Use system clipboard in vi-copy mode in tmux

I'm running tmux 1.6 and I'm trying to configure it to use vi-style keybindings as well as use the system clipboard when copying in interactive mode: set-window-option -g mode-keys vi bind-key -t vi-...
user avatar
  • 35.5k
10 votes
1 answer
5k views

xclip does not change the clipboard content

I'm trying to give the following command: echo "hi" | xclip -selection c This doesn't work? It has worked in the past, but never consistently. I also tried echo "hi" | xclip -selection primary ...
user avatar
  • 313
15 votes
2 answers
3k views

Copy markdown input to the clipboard as rich text

I'm about to get involved in some collaborative prose writing with a friend of mine via email. As a regular person, he will of course be using MS Word document formats; as a massive nerd, I prefer to ...
user avatar
  • 6,361
9 votes
6 answers
7k views

tmux xclip copy no longer working

On mu Ubuntu 12.04 setups my tmux clipboard copy and paste commands are setup as follows: set -g prefix M-a unbind C-b bind C-c run "tmux save-buffer - | xclip -i -sel clipboard" bind C-v run "tmux ...
user avatar
13 votes
2 answers
5k views

How to target multiple selections with xclip

When copying text to the clipboard, xclip provides several selection targets: -selection specify which X selection to use, options are: "primary" to use XA_PRIMARY (default), "secondary"...
user avatar
125 votes
17 answers
114k views

Getting tmux to copy a buffer to the clipboard

I am trying to figure out a decent way to copy what I have in a tmux buffer into my clipboard. I have tried a couple of different things like bind-key p select-pane -t 2 \; split-window 'xsel -i -b'...
user avatar