Copy/paste text in Urxvt (rxvt-unicode) using keyboard
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") {
$self->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.
Written by Pablo
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Terminal
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#