118 votes
Accepted

How to copy and paste with a mouse with tmux

Put this block of code in your ~/.tmux.conf. This will enable mouse integration letting you copy from a pane with your mouse without having to zoom. set -g mouse on bind -n WheelUpPane if-shell -F -t =...
GMaster's user avatar
  • 6,332
106 votes
Accepted

Is Vim immune to copy-paste attack?

Short answer: In many situations, Vim is vulnerable to this kind of attack (when pasting text in Insert mode). Proof of concept Using the linked article as a starting point, I was able to quickly ...
Anthony Geoghegan's user avatar
90 votes
Accepted

Copy selection to a clipboard in tmux

Tmux 2.4+ with vi copy mode bindings and xclip: set-option -g mouse on set-option -s set-clipboard off bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel "xclip -...
Josh Brobst's user avatar
  • 1,465
43 votes
Accepted

Bash command to copy before cursor and paste after?

There are a number of tricks (there's a duplicate to be found I think), but for this I tend to do cp /etc/prog/dir1/myconfig.yml{,.bak} which gets expanded to your command. This is known as brace ...
Stephen Kitt's user avatar
40 votes

Copy selection to a clipboard in tmux

Yet another extension is about using Shift key. Hold Shift while selecting text with mouse. Now you get a standard right-click menu (keep holding or press Shift again) and you can use Ctrl+Shift+C ...
Dušan Maďar's user avatar
34 votes

Copying & Pasting with URxvt

There are built-in mechanisms for copying/pasting to/from PRIMARY (is used when the user selects some data) and CLIPBOARD (is used when the user selects some data and explicitly requests it to be "...
petRUShka's user avatar
  • 1,272
33 votes

Rebinding CTRL-ALT-[C|V] to CTRL-SHIFT-[C|V] in URxvt >= 9.20

The eval extension shipped with rxvt-unicode has paste_clipboard and selection_to_clipboard actions for this, that can be bound to any keysym (see here). In your .Xresources add: URxvt.keysym.Shift-...
Enno's user avatar
  • 461
27 votes

virt-manager copy paste functionality to the vm

You need to install Spice guest agent into the guest: spice-guest-tools for Windows guest spice-vdagent for linux guest Check "Guest" part of Spice downloads section: https://www.spice-space.org/...
Tharok's user avatar
  • 392
25 votes

How can I copy text from xterm (Awesome, Debian, VirtualBox)?

It is not necessary to modify the xterm translations resources to copy data to/from Firefox, unless you prefer to use the keyboard to help with the process. Since 2006 xterm has a feature ...
Thomas Dickey's user avatar
25 votes
Accepted

Double click selection in Gnome Terminal

How much is selected on double click can be configured via adding additional character classes to the default set. That means that adding a colon and other special characters that may show up in URLs ...
maxschlepzig's user avatar
  • 57.6k
23 votes

tmux: Select and copy pane text with mouse

It depends on the version of tmux. When tmux mouse is on then the mouse selections will not span panes and will be copied into tmux's selection buffer. When tmux mouse is off (as it is in the ...
Joseph Tingiris's user avatar
23 votes
Accepted

How do I copy and paste with Kitty?

Kitty You need to use a capital C. To copy and paste in Select text Press CTRL+SHIFT+C Paste with SHIFT+INSERT in any app. There is no method to copy with the cursor. Vim Because things like VIM ...
Evan Carroll's user avatar
  • 30.9k
23 votes

Copy & paste cleanly into a command like grep, without terminal echo cluttering the output?

Mark the text with your mouse, then use xclip: xclip -o | grep FAIL or copied from Clipboard (Ctrl-c): xclip -selection clipboard -o | grep FAIL Or: xclip -sel c -o | grep FAIL for short.
pLumo's user avatar
  • 22.6k
20 votes

How to copy and paste with a mouse with tmux

Add this 2 lines in ~/.tmux.conf set -g @plugin 'tmux-plugins/tmux-yank' set -g mouse on and then install the plugin works for me. https://github.com/tmux-plugins/tmux-yank
Casper Tsui's user avatar
20 votes
Accepted

QEMU/KVM Windows 10 Guest won't copy/paste text or files back to host

I made it work with Debian 10 host, and a Windows 10 guest, in both directions. install virt-manager install the spice-guest-tools in windows (it has a non-costly license on http://spice-space.org/) ...
Thierry Vilmart's user avatar
17 votes

Copying & Pasting with URxvt

You can make urxvt copy to both Primary and Clipboard with the selection-to-clipboard perl extenion. This keeps them in sync, so you just copy once in urxvt and it should work in applications that use ...
degenerateJoe's user avatar
17 votes

Copy & paste cleanly into a command like grep, without terminal echo cluttering the output?

If you are using bash or any other Bourne-like shell, you can use a here-document. Begin your command with grep FAIL << 'EOF' and press Enter. Bash will prompt with a > symbol to show that ...
Jim L.'s user avatar
  • 8,007
16 votes

Getting tmux to copy a buffer to the clipboard

Here is an attempt at a comprehensive answer. First a little history When this question was first asked (June, 2011) copying text from Tmux to the clipboard had to be a two-step process, first copy ...
Jason Axelson's user avatar
16 votes

tmux: Select and copy pane text with mouse

I'm not sure about 2.7, I'm using tmux 3.1c. With 3.1c, you can press prefix+z to maximize ("zoom") the pane (where prefix is Ctrl+b by default). Then, you can do your copying, and prefix+z ...
Xin's user avatar
  • 161
16 votes

Copy & paste cleanly into a command like grep, without terminal echo cluttering the output?

You can use sponge to soak up all the stdin before writing it to stdout. (On Debian it's in the package moreutils.) grep FAIL | sponge or sponge | grep FAIL If you don't have sponge you can ...
Chris Davies's user avatar
16 votes
Accepted

How to copy/paste between a console and an X session?

The "best" way to achieve that sort of thing is almost probably opinion based. The way I prefer uses the backlog of the native terminal. Knowing that the backlog of tty[N] can be accessed ...
MC68020's user avatar
  • 7,981
15 votes

How to toggle or turn off text selection being sent to the clipboard

I was messing around and accidentally enabled the Synchronize contents of the clipboard and the selection option in KDE Plasma's Clipboard application. Un-checking this solved a similar problem for me....
Batandwa's user avatar
  • 251
15 votes

How to make a file with content from the clipboard without opening the file?

xsel’s default behaviour depends on whether its input or output is connected to a terminal, so redirecting to and from files typically does the right thing. As mentioned by codeforester, the solution ...
Stephen Kitt's user avatar
13 votes

tmux mouse scrolling without altering copy/paste?

Hold the shift key when attempting to copy and paste when in 'mode-mouse on'
baligena's user avatar
  • 231
13 votes

Copy selection to a clipboard in tmux

As an extension to the accepted answer, people often find that disturbing when releasing the mouse button exits the copy-mode (this is what happens with copy-pipe-and-cancel). See: https://github.com/...
Gabor Marton's user avatar
12 votes

Copy image from command-line to clipboard

See the answer here: https://askubuntu.com/a/759660/187689 xclip -selection clipboard -t image/png -i example.png
iman's user avatar
  • 251
12 votes

Bash command to copy before cursor and paste after?

History expansion can be useful for this kind of thing (assuming bash history is enabled). In your example, you could do: cp /etc/prog/dir1/myconfig.yml !#:1.bak Here, the !# refers to the current ...
Pooping's user avatar
  • 141
12 votes
Accepted

How do command line clipboard tools like "xclip" and "xsel" persist the clipboard - in a X windows environment that doesn't?

Unless there's a clipboard application like xclipboard, clipit... that steals the selections from them, xsel/xclip will fork a background process to handle the future selection requests as long as ...
Stéphane Chazelas's user avatar
12 votes

Any function copying from clipboard to a variable in Bash?

Strictly speaking, no. Bash itself has no awareness of your clipboard. However, there are some command line utilities for interacting with the clipboard, but they vary from OS to OS. On Linux, the ...
Greg Nisbet's user avatar
  • 3,076
11 votes

Copy-paste for vim is not working when mouse (:set mouse=a) is on?

Had the same problem: could not highlight using the mouse so could not copy and paste from VIM in a terminal session to Windows document and browser: Did the following and it now works: : set ...
Bob's user avatar
  • 111

Only top scored, non community-wiki answers of a minimum length are eligible