Sample Header Ad - 728x90

Unix & Linux Stack Exchange

Q&A for users of Linux, FreeBSD and other Unix-like operating systems

Latest Questions

2 votes
1 answers
548 views
nano command execution stuck
In `nano` v8.0 there's an option to send selection to X clipboard in the `nanorc`: "{execute}|xsel -ib{enter}{undo}" which does perfectly. I tried using `xclip` utility instead: "{execute}|xclip -sel c{enter}{undo}" The result was an infinite execution `[ Executing... ]`, insensitive to interaction...
In nano v8.0 there's an option to send selection to X clipboard in the nanorc: "{execute}|xsel -ib{enter}{undo}" which does perfectly. I tried using xclip utility instead: "{execute}|xclip -sel c{enter}{undo}" The result was an infinite execution [ Executing... ], insensitive to interaction until hit ^C. After the cancelling it appeared done the copying, no errors, but what's with the stuckage? Why does it happen and is there a fix? I'm on Kubuntu 20.04.6 LTS (Focal Fossa).
Multifix (145 rep)
May 5, 2024, 12:25 PM • Last activity: May 6, 2024, 02:10 PM
0 votes
1 answers
241 views
Find X Atom of given Window?
Using [_DWM_](https://git.suckless.org/dwm/log.html) as my Window-Manager under _Archlinux_ I don't have any patches to handle context menus or "right-click" functionalities. This being the case I decided to write a concise _Bash_ alias that runs `xclip` (which I can later re-map to mouse buttons us...
Using [_DWM_](https://git.suckless.org/dwm/log.html) as my Window-Manager under _Archlinux_ I don't have any patches to handle context menus or "right-click" functionalities. This being the case I decided to write a concise _Bash_ alias that runs xclip (which I can later re-map to mouse buttons using _libinput_ and such). My issue now though is that I am trying to re-direct my xclip selections to a specific window but I'm not finding how I can grab the _X_ _Atom_ with any commands so far. I've tried xprop and xwininfo but none of the data returned matches the _Atom_. Any help or insight is appreciated.
tijko (265 rep)
Apr 9, 2024, 04:52 AM • Last activity: Apr 23, 2024, 04:05 PM
96 votes
10 answers
103033 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-copy 'v' begin-selection bind-key -t vi-copy 'y' "copy-selection && run \"tmux save-buffer | xclip -s...
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-copy 'v' begin-selection bind-key -t vi-copy 'y' "copy-selection && run \"tmux save-buffer | xclip -selection clipboard\"" Simply put, I'd like to be able to do C+[ and then use v to begin selecting text for copying, then when y is pushed, copy the selection to the tmux selection and then export it to the system clipboard using xclip. Unfortunately, when I try to do this, I see the following: .tmux.conf: 14: unknown command: copy-selection && run "tmux save-buffer | xclip -selection clipboard" Is there a way to do this in tmux configuration?
Naftuli Kay (41346 rep)
May 19, 2014, 07:27 PM • Last activity: Mar 8, 2024, 03:41 PM
0 votes
0 answers
43 views
Are there two different clipboards? Why does copy/paste work differently depending upon keys used (shift-insert & ctrl-v)?
It's as if there are two different system clipboards (stash places for copied text), with two different ways of accessing them. I've noticed this for quite some time but never been able to narrow it down to a question. **Here's How You Can Recreate This** Use the xclip command to copy some text on t...
It's as if there are two different system clipboards (stash places for copied text), with two different ways of accessing them. I've noticed this for quite some time but never been able to narrow it down to a question. **Here's How You Can Recreate This** Use the xclip command to copy some text on the clipboard like the following: $ echo this is a test | xclip When you do that, you can access that stashed data only using Shift-Insert. 1. You cannot access that stashed data via Ctrl-V 2. You cannot access that stashed data via ContextMenu (right-click) and Paste - The paste option will be greyed out because it doesn't think there is anything on the system clipboard, or it will have older data that was copied to the clipboard. **To Prove That** To prove that true, after running the command above you can attempt to paste the text using Ctrl-V and ContextMenu Paste. Neither will work. However, Shift-Insert (which is an old key combination, possibly originated in WordStar) will indeed paste the text that is stashed by xclip. **Note**: If you have a keyboard that doesn't have a dedicated Insert key then you'll need to turn your num-lock key on and use the one that should be located on your numeric keypad. **Another Thing To Try** I also noticed that to get the text from xclip I can run the following command: $ xclip -o However, I discover that at times the stashed data that is displayed from xclip is entirely different data than the data that I get from Ctrl-V or ContextMenu-Paste Can anyone explain this? Where is data stashed? Is there only one clipboard?
raddevus (123 rep)
Nov 11, 2023, 04:57 PM
11 votes
1 answers
1358 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 source application is (e.g. perhaps by PID). Why? If the source application is a terminal, I'd like to...
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 source application is (e.g. perhaps by PID). Why? If the source application is a terminal, I'd like to find the working directory of the terminal, in case the copied contents is a relative path, to construct a full path to a file. FYI, I'm currently using xclip to determine the clipboard contents, e.g. xclip -selection primary -t STRING -o 2> /dev/null
Jeff Ward (693 rep)
Jun 22, 2015, 08:09 PM • Last activity: Aug 14, 2023, 02:07 AM
6 votes
2 answers
593 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 composing, it replaces all of the line breaks with spaces (and if there are multiple line breaks in a...
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 composing, it replaces all of the line breaks with spaces (and if there are multiple line breaks in a row, it turns all of them collectively into a single space). When I paste it elsewhere, I don't have this issue. However, when I copy from somewhere like Leafpad and paste it into a Gmail email in Firefox, it retains the line breaks. The same problem doesn't happen with Gmail in the Chromium web browser. Why does this happen, and is there a way to fix it so it doesn't strip out the line breaks? I'm using xclip 0.12 on Xubuntu 16.10, 64-bit. Here's the command I use to copy the text: xclip -selection clipboard [seeBelow] I use this line of Python code to insert the text where I have [seeBelow] above: subprocess.Popen(command, stdin=subprocess.PIPE).communicate(text.encode()); I am copying the text from a Python3 Tkinter multi-line Text widget (well, a widget that inherits Text, and should be practically the same for our purposes). The problem just seems to happen in Gmail within Firefox. That is a place I frequently like to paste, however, as I often write my emails in my editor.
Brōtsyorfuzthrāx (297 rep)
Aug 5, 2017, 08:08 AM • Last activity: Aug 6, 2023, 11:07 AM
7 votes
2 answers
1011 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 -t image/gif < /path/to/image.gif
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 -t image/gif < /path/to/image.gif
charlespwd (171 rep)
Jul 31, 2018, 04:58 PM • Last activity: May 28, 2023, 11:25 AM
135 votes
17 answers
132537 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' \; paste-buffer which gets me fairly close, all I have to do is hit control-d after I do prefix-p. I...
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' \; paste-buffer which gets me fairly close, all I have to do is hit control-d after I do prefix-p. I tried fixing that by doing bind-key p select-pane -t 2 \; split-window 'xsel -i -b << HERE\; tmux paste-buffer\; echo HERE' But that just doesn't work. In fact if I pair this down to just bind-key p select-pane -t 2 \; split-window 'xsel -i -b << HERE' it doesn't do anything so I am assuming that split-window doesn't like << in a shell command. Any ideas? Edit: You can skip the select-pane -t 2 if you want, it isn't really important. I just use a specific layout and pane 2 is the one I prefer to split when I doing something else so that goes into my bindings involving splits by default.
Digital Powers (1857 rep)
Jun 27, 2011, 08:14 PM • Last activity: May 13, 2023, 03:34 PM
5 votes
2 answers
311 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 only the first character of the selection specified with the -selection option is important. This means tha...
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 only the first character of the selection specified with the -selection option is important. This means that "p", "sec" and "clip" would have the same effect as using "primary", "secondary" or "clipboard" respectively. The following for using clipboard selection works xclip -sel clip < ~/.ssh/id_rsa.pub the manpage says that clipboard can be shortened to clip, but doesn't say that -selection can be shortened to -sel. So why does it work? Does this feature for specifying an option belong to xclip, or also to many other applications besides xclip?
Tim (106420 rep)
Jun 11, 2016, 06:11 PM • Last activity: May 4, 2023, 01:25 AM
3 votes
1 answers
9120 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 + v` in terminal > **Cut**: `ctrl + x` in programs, does not work properly in termi...
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 + v in terminal > **Cut**: ctrl + x in programs, does not work properly in terminal To: > **Copy**: Win + c everywhere > **Paste**: Win + v everywhere > **Cut**: Win + x everywhere How can I achive this ? Thank you for your help PS: I am using: Arch linux, xserver, i3wm, xclip, alacritty
Jan Čern&#253; (1723 rep)
Sep 9, 2020, 09:05 PM • Last activity: Apr 12, 2023, 11:38 AM
0 votes
1 answers
112 views
Is there a way to append text to xclip?
I need to store data in xclip multiple times - i.e. keep appending more chucks of text to xclip. But it doesn't look like this option is available. Is there a clever hack for this? I want to avoid using temporary files.
I need to store data in xclip multiple times - i.e. keep appending more chucks of text to xclip. But it doesn't look like this option is available. Is there a clever hack for this? I want to avoid using temporary files.
userene (1856 rep)
Mar 31, 2023, 09:51 AM • Last activity: Mar 31, 2023, 09:56 AM
0 votes
1 answers
249 views
How to create a keyboard shortcut for playing youtube videos with mpv?
I'm using Pop OS. I've aliased the command `mpv $(xclip -o) & exit` to `pp` so I can play youtube links copied to my clipboard with mpv player in lesser keystrokes in the terminal. I realised I may also do this without even having to open the terminal by creating a 'custom shortcut'(in Pop OS keyboa...
I'm using Pop OS. I've aliased the command mpv $(xclip -o) & exit to pp so I can play youtube links copied to my clipboard with mpv player in lesser keystrokes in the terminal. I realised I may also do this without even having to open the terminal by creating a 'custom shortcut'(in Pop OS keyboard settings) for the aforementioned command. My attempt at the solution - I tried to assign the custom keys to gnome-terminal -- mpv $(xclip -o) and when it didn't work out I shortened it to mpv $(xclip -o) but with no success. Nothing happened after I pressed the assigned shortcut keys. The question - How do I create a system-wide custom keyboard shortcut to play youtube videos with mpv with help of the command mpv $(xclip -o) & exit ?
Archit (1 rep)
Oct 14, 2022, 11:10 AM • Last activity: Feb 16, 2023, 10:41 PM
1 votes
1 answers
343 views
Disable automatically copying selection to clipboard in urxvt
There are 2 kind of clipboards on my os (manjaro i3). Xclip, which keeps the last selected text, and the regular clipboard which must be explicitly copied. I have noticed urxvt copies selected text in both clipboard, but I only need it to copy to xclip instead of the regular clipboard. Is there a wa...
There are 2 kind of clipboards on my os (manjaro i3). Xclip, which keeps the last selected text, and the regular clipboard which must be explicitly copied. I have noticed urxvt copies selected text in both clipboard, but I only need it to copy to xclip instead of the regular clipboard. Is there a way to do this? Edit: my Xresources URxvt.clipboard.autocopy: false URxvt.font: 9x15,xft:TerminessTTFNerdFontMono ! URxvt.font: -xos4-terminus-medium-r-normal--16-160-72-72-c-80-iso10646-1 ! URxvt.bold.font: -xos4-terminus-bold-r-normal--16-160-72-72-c-80-iso10646-1 URxvt.depth: 32 URxvt.background: #222D31 URxvt*scrollBar: false URxvt*mouseWheelScrollPage: false URxvt*cursorBlink: true URxvt*background: black URxvt*foreground: grey URxvt*saveLines: 5000 ! URxvt*inheritPixmap: true ! URxvt*transparent: true ! URxvt*shading: 138 URxvt*transparent: true URxvt*shading: 20 URxvt.iso14755: false URxvt.keysym.Shift-Control-V: eval:paste_clipboard URxvt.keysym.Shift-Control-C: eval:selection_to_clipboard URxvt.keysym.Control-Left: \033[1;5D URxvt.keysym.Shift-Control-Left: \033[1;6D URxvt.keysym.Control-Right: \033[1;5C URxvt.keysym.Shift-Control-Right: \033[1;6C URxvt.keysym.Control-Up: \033[1;5A URxvt.keysym.Shift-Control-Up: \033[1;6A URxvt.keysym.Control-Down: \033[1;5B URxvt.keysym.Shift-Control-Down: \033[1;6B URxvt.perl-ext-common: default,font-size,clipboard,selection-to-clipboard ! URxvt.keysym.M-C-c: perl:clipboard:copy ! URxvt.keysym.M-v: perl:clipboard:paste ! URxvt.keysym.M-C-v: perl:clipboard:paste_escaped ! URxvt*termName: string ! URxvt*geometry: geometry ! URxvt*chdir: string ! URxvt*loginShell: boolean ! URxvt*multiClickTime: number ! URxvt*jumpScroll: boolean ! URxvt*skipScroll: boolean ! URxvt*pastableTabs: boolean ! URxvt*scrollstyle: plain ! URxvt*scrollBar_right: boolean ! URxvt*scrollBar_floating: true ! URxvt*scrollBar_align: mode ! URxvt*thickness: number ! URxvt*scrollTtyOutput: boolean ! URxvt*scrollTtyKeypress: boolean ! URxvt*scrollWithBuffer: boolean ! URxvt*tintColor: !7DA55 ! URxvt*blurRadius: HxV ! URxvt*fading: number ! URxvt*fadeColor: color ! URxvt*utmpInhibit: boolean ! URxvt*urgentOnBell: boolean ! URxvt*visualBell: boolean ! URxvt*mapAlert: boolean ! URxvt*meta8: boolean ! URxvt*tripleclickwords: boolean ! URxvt*insecure: boolean ! URxvt*cursorUnderline: boolean ! URxvt*pointerBlank: boolean ! URxvt*color0: color ! URxvt*color1: color ! URxvt*color2: color ! URxvt*color3: color ! URxvt*color4: color ! URxvt*color5: color ! URxvt*color6: color ! URxvt*color7: color ! URxvt*color8: color ! URxvt*color9: color ! URxvt*color10: color ! URxvt*color11: color ! URxvt*color12: color ! URxvt*color13: color ! URxvt*color14: color ! URxvt*color15: color ! URxvt*colorBD: color ! URxvt*colorIT: color ! URxvt*colorUL: color ! URxvt*colorRV: color ! URxvt*underlineColor: color ! URxvt*scrollColor: color ! URxvt*troughColor: color ! URxvt*highlightColor: color ! URxvt*highlightTextColor: color ! URxvt*cursorColor: color ! URxvt*cursorColor2: color ! URxvt*pointerColor: color ! URxvt*pointerColor2: color ! URxvt*borderColor: color ! URxvt*iconFile: file ! URxvt*font: fontname ! URxvt*boldFont: fontname ! URxvt*italicFont: fontname ! URxvt*boldItalicFont: fontname ! URxvt*intensityStyles: boolean ! URxvt*inputMethod: name ! URxvt*preeditType: style ! URxvt*imLocale: string ! URxvt*imFont: fontname ! URxvt*title: string ! URxvt*iconName: string ! URxvt*buffered: boolean ! URxvt*depth: number ! URxvt*visual: number ! URxvt*transient-for: windowid ! URxvt*override-redirect: boolean ! URxvt*hold: boolean ! URxvt*externalBorder: number ! URxvt*internalBorder: number ! URxvt*borderLess: true ! URxvt*lineSpace: number ! URxvt*letterSpace: number ! URxvt*skipBuiltinGlyphs: boolean ! URxvt*pointerBlankDelay: number ! URxvt*backspacekey: string ! URxvt*deletekey: string ! URxvt*print-pipe: string ! URxvt*modifier: modifier ! URxvt*cutchars: string ! URxvt*answerbackString: string ! URxvt*secondaryScreen: boolean ! URxvt*secondaryScroll: boolean ! URxvt*perl-lib: string ! URxvt*perl-eval: perl-eval ! URxvt*perl-ext-common: string ! URxvt*perl-ext: string ! URxvt*iso14755: boolean ! URxvt*iso14755_52: boolean ! URxvt*xrm: string ! URxvt*keysym.sym: keysym ! URxvt*background.border: boolean ! URxvt*background.expr: string ! URxvt*background.interval: seconds ! URxvt*bell-command: string ! URxvt*kuake.hotkey: string ! URxvt*matcher.button: string ! URxvt*matcher.launcher: string ! URxvt*matcher.launcher.*: string ! URxvt*matcher.pattern.*: string ! URxvt*matcher.rend.*: string ! URxvt*remote-clipboard.fetch: string ! URxvt*remote-clipboard.store: string ! URxvt*searchable-scrollback: string ! URxvt*selection-autotransform.*: string ! URxvt*selection-pastebin.cmd: string ! URxvt*selection-pastebin.url: string ! URxvt*selection.pattern-0: string ! URxvt*tab-bg: colour ! URxvt*tab-fg: colour ! URxvt*tabbar-bg: colour ! URxvt*tabbar-fg: colour ! URxvt*url-launcher: string !URxvt.font:xft:DejaVu Sans Mono:pixelsize=28
user2741831 (323 rep)
Jan 10, 2023, 01:57 PM • Last activity: Jan 11, 2023, 01:18 PM
9 votes
2 answers
1303 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 &#8984;V shortcut. My setup connects to the remote machine with `ssh -Y` and then attaches to tmux (or creates a new session if non-existent). When I ru...
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 machine with ssh -Y and then attaches to tmux (or creates a new session if non-existent). When I run either echo "test" | xsel -ib or echo "test" | xclip it hangs. The $DISPLAY variable is localhost:10.0. If I exit tmux the $DISPLAY variable seems to be null and I get a can't open display error.
Kvass (221 rep)
Jan 4, 2017, 11:25 PM • Last activity: Jan 7, 2023, 12:36 PM
5 votes
4 answers
3306 views
xclip works differently in interactive and non-interactive shells
While investigating a problem described in [a question at stackoverflow](https://stackoverflow.com/questions/40061058/code-in-shell-script-runs-before-other-operations#comment67399516_40061058) I simplified it down to a test case demonstrating that in non-interactive mode bash seems to clear the X s...
While investigating a problem described in [a question at stackoverflow](https://stackoverflow.com/questions/40061058/code-in-shell-script-runs-before-other-operations#comment67399516_40061058) I simplified it down to a test case demonstrating that in non-interactive mode bash seems to clear the X system clipboard before exiting. The test opens a gnome terminal and runs a bash script in it that places (via xclip) some text in the X system clipboard. While the terminal is open, querying the clipboard returns the text that was placed in it regardless of whether bash is run in interactive or non-interactive mode. However, after the terminal is closed, the clipboard contents survives if bash was run in interactive mode, but is lost if bash was run in non-interactive mode. $ cat xclip_test #!/usr/bin/env bash set -x gnome-terminal -x bash -i -c "echo abc|xclip -selection clipboard; sleep 3" sleep 1 xclip -o -selection clipboard sleep 4 xclip -o -selection clipboard gnome-terminal -x bash -c "echo 123|xclip -selection clipboard; sleep 3" sleep 1 xclip -o -selection clipboard sleep 4 xclip -o -selection clipboard $ ./xclip_test + gnome-terminal -x bash -i -c 'echo abc|xclip -selection clipboard; sleep 3' + sleep 1 + xclip -o -selection clipboard abc + sleep 4 + xclip -o -selection clipboard abc + gnome-terminal -x bash -c 'echo 123|xclip -selection clipboard; sleep 3' + sleep 1 + xclip -o -selection clipboard 123 + sleep 4 + xclip -o -selection clipboard Error: target STRING not available #!!!!!!!!!!!!! I am on Ubuntu 16.04, using default GNU bash (version 4.3.46(1)-release (x86_64-pc-linux-gnu)) with no customizations to bash rc files. I checked .bash_logout just in case and found a call to clear_console utility. However clear_console doesn't seem to deal with the clipboard; besides, the example doesn't run bash as a login shell. Is this something having a sensible explanation? **EDIT** The problem persists when replacing gnome-terminal with xterm: **gnome-terminal -x** ... --> **xterm -e** ... **&** Also it is not unique to bash - it is reproduced with dash, too.
Leon (191 rep)
Oct 16, 2016, 10:34 AM • Last activity: Dec 13, 2022, 07:30 PM
1 votes
1 answers
257 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 script that aims to capture a part of the screen with `gnome-screenshot` into a PNG file, inspect t...
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 script that aims to capture a part of the screen with gnome-screenshot into a PNG file, inspect that file with zbarimg and make whatever it outputs available to be pasted with xclip. Here's what I wrote: tfile=$(mktemp -u -p ~).png && gnome-screenshot -a -f $tfile && zbarimg -q --raw $tfile | xclip; rm $tfile Just after I run this script it does request me to capture a part of the screen (exactly what gnome-screenshot is supposed to do), the screenshot file is created, but after that it seems that xclip runs and waits for input forever, as if zbarimg didn't output anything. Does anyone have a suggestion to solve this issue?
Ramiro (131 rep)
Jan 26, 2018, 07:44 PM • Last activity: Oct 15, 2022, 07:58 AM
2 votes
2 answers
1086 views
No new line when piping into xclip
Is there something I can do so that whenever I pipe something into `xclip` it does not include a new line at the end? As a workaround, I am using `echo -n $(CMD_TO_COPY) | xclip`, but it's kind of annoying having to type all of this each time I want to copy something.
Is there something I can do so that whenever I pipe something into xclip it does not include a new line at the end? As a workaround, I am using echo -n $(CMD_TO_COPY) | xclip, but it's kind of annoying having to type all of this each time I want to copy something.
nicolasbk (43 rep)
Aug 8, 2022, 01:05 PM • Last activity: Aug 8, 2022, 03:48 PM
1 votes
0 answers
673 views
how to pipe Wayland clipboard into an X vnc session clipboard over ssh
I am using Wayland on Arch, and am `ssh`ed into a debian server which uses X11. I have a vnc session running over that ssh connection. I would like to take a string that I have stored in my Wayland clipboard, and put it into the X clipboard on the server so that I can use that string with `ctrl+v` i...
I am using Wayland on Arch, and am sshed into a debian server which uses X11. I have a vnc session running over that ssh connection. I would like to take a string that I have stored in my Wayland clipboard, and put it into the X clipboard on the server so that I can use that string with ctrl+v in the vnc session. I thought this would be as simple as opening a terminal emulator via vnc, checking the $DISPLAY variable there, then using echo "string" | xclip -d ':display' -selection clipboard in my ssh session (I can just use ctrl+shift+v in my local terminal emulator to paste the string into the command). However, that does not work. It seems to copy fine, but then clipboard -o -d ':display' -selection clipboard shows the previous thing in the clipboard, and not the thing I just tried to copy. So far, I've been doing echo "string" > tmpfile, then opening the file in a text editor in the vnc session, and copying it from there. However, that is clunky. Obviously, the ideal solution would be to take the time to reconfigure my server so that I can access it remotely in a more sensible manner, but that would take time. I'd like a solution I can use in the meantime, and I'd like to understand why the above method doesn't work like I expected.
mangoduck (53 rep)
Jun 22, 2022, 07:32 PM
2 votes
0 answers
513 views
How to paste selection from vi-mode to clipboard
I want to access the content of what I copied in the buffer with the vi-mode of the clipboard via the command `ctrl` + `v` or `ctrl` + `shift` + `v` in the terminal. I copied in my .zshrc the following: (from this answer: https://unix.stackexchange.com/questions/25765/pasting-from-clipboard-to-vi-en...
I want to access the content of what I copied in the buffer with the vi-mode of the clipboard via the command ctrl + v or ctrl + shift + v in the terminal. I copied in my .zshrc the following: (from this answer: https://unix.stackexchange.com/questions/25765/pasting-from-clipboard-to-vi-enabled-zsh-or-bash-shell)
vi-append-x-selection () { RBUFFER=$(xsel -o -p 
When I highlight something in the terminal in vi-mode and yank it, I can successfully retrieve it by typing Ctrl + shift + y. However when I type Ctrl + shift + v, something else in being pasted. When I inspect the content of the clipboard with the following commands:
xclip -o sel p
xclip -o sel s
xclip -o sel c
xsel -o -p
xsel -o -s
xsel -o -b
it contains other string that I peviously copied with other means but NOT what I highlighted in vi-mode. Here is my **first question**: if I can retrieve it with the command Ctrl + shift + y and confirm that with xsel and xclip that it is not in one of the three buffer ("primary", "secondary" and "clipboard") where is stored then???) I also tried to replace the '^Y' by '^V' in the line
bindkey -a '^Y' vi-yank-x-selection
(as follows:)
bindkey -a '^V' vi-yank-x-selection
Without any success (it seems to print out an empty buffer) **my second question**: What am I doing wrong?
ecjb (475 rep)
May 26, 2022, 01:25 PM • Last activity: May 27, 2022, 10:16 PM
1 votes
0 answers
319 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, and the modification gets pasted back to the active window. My attempt is shown below. At the moment,...
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, and the modification gets pasted back to the active window. My attempt is shown below. At the moment, the part where I do ctrl+a and ctrl+c does not work.
#!/usr/bin/env bash

TMPFILE=$(mktemp).md

if [[ $OSTYPE == "linux-gnu" ]]; then
    xdotool getactivewindow key ctrl+a
    xdotool getactivewindow key ctrl+c
    xclip -selection clipboard -o > $TMPFILE
    urxvt -fn "xft:Iosevka Term:pixelsize=24" -geometry 60x10 -e vim -u ~/.config/vim/vimrc -c 'startinsert' $TMPFILE
    cat $TMPFILE | xclip -selection clipboard
    xdotool key ctrl+v
fi
Chad Winters (111 rep)
Apr 28, 2022, 07:48 PM
Showing page 1 of 20 total questions