I’m using URxvt 9.20 on debian jessie and I’m looking for a way to copy & paste text like I was used to with the gnome-terminal (Ctrl+Insert for copying, Shift+Insert for pasting).
It works within different urxvt consoles, it does not work between e.g. urxvt and iceweasel though.
I tried according to the manual on archlinux, but it won’t work (even though I actually don’t want to use Shift+Ctrl+C/V it was worth a try).
.Xresources:
! ****************** ! urxvt config ! ****************** ! Disable Perl extension ! If you do not use the Perl extension features, you can improve the security ! and speed by disabling Perl extensions completely. URxvt.perl-ext: URxvt.perl-ext-common: ! Font spacing ! By default the distance between characters can feel too wide. It's controlled ! by this entry: ! URxvt.letterSpace: -1 ! -- Fonts -- ! URxvt.font:xft:Monospace:pixelsize=13 URxvt.boldfont:xft:Monospace-Bold:pixelsize=13 !URxvt*font: -xos4-terminus-medium-*-*-*-14-*-*-*-*-*-iso8859-15,xft:terminus:pixelsize:12 !URxvt*boldFont: -xos4-terminus-bold-*-*-*-14-*-*-*-*-*-iso8859-15,xft:terminus:bold:pixelsize:12 !URxvt*italicFont: xft:Bitstream Vera Sans Mono:italic:autohint=true:pixelsize=12 !URxvt*boldItalicFont: xft:Bitstream Vera Sans Mono:bold:italic:autohint=true:pixelsize=12 ! Disable scrollbar !URxvt*scrollBar: false ! Scrollbar style - rxvt (default), plain (most compact), next, or xterm URxvt.scrollstyle: plain ! Background color !URxvt*background: black URxvt*background: #1B1B1B ! Font color !URxvt*foreground: white URxvt*foreground: #00FF00 ! Other colors URxvt*color0: black !URxvt*color1: red3 URxvt*color1: #CD0000 URxvt*color2: green3 !URxvt*color3: yellow3 URxvt*color3: #C4A000 URxvt*color4: blue2 !URxvt*color4: #3465A4 URxvt*color5: magenta3 URxvt*color6: cyan3 URxvt*color7: gray90 URxvt*color8: grey50 URxvt*color9: red URxvt*color10: green URxvt*color11: yellow !URxvt*color12: blue URxvt*color12: #3465A4 URxvt*color13: magenta URxvt*color14: cyan URxvt*color15: white ! ****************** ! /urxvt config ! ******************
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
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 “copied” to the clipboard, such as by invoking “Copy” under the “Edit” menu of an application). More about different clipboards in X.
For CLIPBOARD buffer it is CTRL+META+C (which is CTRL+ALT+C for standard PC keyboard) for copying and CTRL+META+V (CTRL+ALT+V) for pasting.
Quotation from urxvt man:
THE SELECTION: SELECTING AND PASTING TEXT
The behaviour of text selection and insertion/pasting mechanism is similar to xterm(1).
Selecting:
Left click at the beginning of the region, drag to the end of the region and release; Right click to extend the marked region;
Left double-click to select a word; Left triple-click to select the
entire logical line (which can span
multiple screen lines), unless modified by resource tripleclickwords.Starting a selection while pressing the Meta key (or Meta+Ctrl keys) (Compile: frills) will create a rectangular selection
instead of a normal one. In this mode, every selected row becomes its
own line in the selection, and trailing
whitespace is visually underlined and removed from the selection.
Pasting:
Pressing and releasing the Middle mouse button in an urxvt window causes the value of the PRIMARY selection (or CLIPBOARD with
the Meta modifier) to be inserted as if it had been typed on the
keyboard.Pressing Shift-Insert causes the value of the PRIMARY selection to be inserted too.
rxvt-unicode also provides the bindings Ctrl-Meta-c and to interact with the CLIPBOARD selection. The first
binding causes the value of the internal selection to be copied to the
CLIPBOARD selection, while the second
binding causes the value of the CLIPBOARD selection to be inserted.
Method 2
For pasting text, in urxvt/rxvt-unicode you can use middle button to paste PRIMARY selection and Alt/Meta+middle button to paste CLIPBOARD.
For copying, just marking the text in the terminal copies it to the PRIMARY selection. Some work is needed for copying to the CLIPBOARD selection though. I combined the information from the Archlinux page you linked with scripts included in rxvt-unicode-9.19 and ended up with a script like this: https://gist.github.com/xkr47/98224ed6b0860cb55ec0. It allows one to use Ctrl+Insert or Ctrl+Shift+c` to copy the currently selected text to CLIPBOARD.
Hope this helps.
For the record, I also don’t run a desktop environment; using Sawfish as window manager.
Tip: You can monitor the clipboard in a terminal using either the “xclip” program:
while :; do echo -ne '33[31;1mCLIPBOARD: ' ; xclip -o -sel c ; echo ; echo -ne '33[32;1mPRIMARY: ' ; xclip -o -sel p ; echo ; echo -e '33[m--------' ; sleep 1 ; done
or using the “xsel” program:
while :; do echo -ne '33[31;1mCLIPBOARD: ' ; xsel -b -o ; echo ; echo -ne '33[32;1mPRIMARY: ' ; xclip -p -o ; echo ; echo -e '33[m--------' ; sleep 1 ; done
Method 3
Unfortunately, the X window system has several different copy-paste mechanisms.
Rxvt, like most old-school X applications, uses the primary selection. Generally, when you select something with the mouse, it’s automatically copied to the primary selection, and when you middle-click to paste, that pastes the primary selection.
Ctrl+C and Ctrl+V (or other key bindings) in applications using modern GUI toolkits, such as Gnome-terminal and Firefox, copy/paste from the clipboard.
There are tools to facilitate working with the selections. In particular, if you just want to have a single selection that’s copied to whether you select with the mouse or press Ctrl+C, you can run autocutsel (start it from your .xinitrc or from your desktop environment’s startup programs), which detects when something is copied to one of the selections and automatically copies it to the other.
Method 4
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 either.
URxvt.perl-ext-common: selection-to-clipboard
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0