Copy/paste text in Urxvt (rxvt-unicode) using keyboard

Posted on

Note: This is a copy of this article. It’s only a reminder for me 😉

We are going to use xclip for copy/paste text in Urxvt. First you have to install xclip. Once xclip is installed, create a file called ‘clipboard’ in ‘/usr/lib/urxvt/perl/’ with this content:

#script to copy/paste text in URXVT
#! perl
sub on_sel_grab {
    my $query = $_[0]->selection;
    open (my $pipe,'| /usr/bin/xclip -in -selection clipboard') or die;
    print $pipe $query;
    close $pipe;
sub paste {
    my ($self) = @_;
    my $content = `/usr/bin/xclip -loop 1 -out -selection clipboard` ;
    $self->tt_write ($content);
sub on_user_command {
    my ($self, $cmd) = @_;
    if ($cmd eq "clipboard:paste") {

Add to your .Xdefaults (or .Xresources) the following lines:

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

That’s it! Enjoy.

Leave a Reply

Your email address will not be published.