Enable Copy-paste Clipboard In URxvt Terminal Emulator

Enable copy-paste clipboard in URxvt Terminal Emulator

In my current Arch Linux installation, I decided to use a window manager called i3. It's really awesome and it comes with a really lightweight terminal emulator called urxvt. It's very minimal and I lked it but when I tried to copy-paste text from one terminal to another, I wasn't able to.

However, thanks to the internet, I did some research and figured a way out.

1. Install xClip

First, you need to ensure that you have installed the xclip package, which will be used to copy-paste text in the emulator.

Type the following command to install the package:

pacman-Sxclip

2. Activate Clipboard using Perl

Now, you have to paste these custom commands into your clipboard file, which is found in /usr/lib/urxvt/perl directory:

# paste selection from clipboard subpaste{ my($self)=@_; my$content=`/usr/bin/xclip -loop 1 -out -selection clipboard`; $self->tt_write($content); } # copy text to clipbard on selection subon_sel_grab{ my$query=$_[0]->selection; open(my$pipe,'| /usr/bin/xclip -in -selection clipboard')ordie; print$pipe$query; close$pipe; }

3. Modify your .Xresources

Add these keybindings to your .Xresources file:

URxvt.keysym.Shift-Control-V:perl:clipboard:paste URxvt.iso14755:False URxvt.perl-ext-common:default,clipboard

After adding it, refresh your .Xresources settings:

xrdb-merge.Xresources

Reboot your terminal and try selecting some text from your terminal using your mouse and paste it using Ctrl+Shift+V and it should work!

That's it! Enjoy 😃

June 20th, 2020
  • Linux

Hello, I'm Abdush Shakoor! 👋

I'm a programmer & designer based in Dubai, United Arab Emirates. I love tinkering with code and writing about what I learn.

Like this article? Please share it with your friends and colleagues or else, send me a private message about your feedback.

  • 👈 Check out more articles!

Tag » Arch I3 Copy Paste