Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[HOWTO] Copy and Paste in urxvt with custom bindings
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
frankenputer
n00b
n00b


Joined: 09 Mar 2016
Posts: 26

PostPosted: Thu Jun 30, 2016 11:23 am    Post subject: [HOWTO] Copy and Paste in urxvt with custom bindings Reply with quote

Hello,

There is a default urxvt extension which allows to copy selected content into the clipboard buffer without pressing any key, it's called selection-to-clipboard.

After reading parts of the urxvtperl man page, I was amazed how easy was to paste selected text:

Code:
sub on_sel_grab {
   warn "you selected ", $_[0]->selection;
   ()
}


I've been using the clipboard extension by Bert for a long time, and after reading the rest of the man page,
I figured out how to paste content from the X11 clipboard buffer which the previous example taken from the man page wasn't able to output.

Filename: pasta

Code:
#! /usr/bin/env perl -w
# Author:   Aaron Caffrey
# Website:  https://github.com/wifiextender/urxvt-pasta
# License:  GPLv3

# Usage: put the following lines in your .Xdefaults/.Xresources:
# URxvt.perl-ext-common           : selection-to-clipboard,pasta
# URxvt.keysym.Control-Shift-V    : perl:pasta:paste

use strict;

sub on_user_command {
  my ($self, $cmd) = @_;
  if ($cmd eq "pasta:paste") {
    $self->selection_request (urxvt::CurrentTime, 3);
  }
  ()
}



Installation

Simply place the script in /usr/lib/urxvt/perl/ for
system-wide availability or in ~/.urxvt/ext/ for user-only availability.
You can also put it in a folder of your choice, but then you have to add this
line to your .Xdefaults/.Xresources:

Code:
# Don't type ~ or $HOME below
URxvt.perl-lib: /home/user/your/folder/


After installing, put the following lines in your .Xdefaults/.Xresources:

Code:
# libs to activate, do not omit selection-to-clipboard
URxvt.perl-ext-common           : selection-to-clipboard,pasta

# keyboard shortcut to trigger the lib
URxvt.keysym.Control-Shift-V    : perl:pasta:paste


Cheers

Edited on next day: tabbedex was causing a nasty bug, which was causing a copied piece of code to be executed when a new tabbedex tab was opened.


Last edited by frankenputer on Fri Jul 01, 2016 12:06 pm; edited 2 times in total
Back to top
View user's profile Send private message
khayyam
Watchman
Watchman


Joined: 07 Jun 2012
Posts: 6227
Location: Room 101

PostPosted: Thu Jun 30, 2016 2:34 pm    Post subject: Re: [HOWTO] Copy and Paste in urxvt with custom bindings Reply with quote

frankenputer wrote:
Code:
# Don't type ~ or $HOME below
URxvt.perl-lib: /home/user/your/folder/

frankenputer ... you can do the following however:

~/.xinitrc:
xrdb -DENV_HOME="$HOME" -load ~/.Xresources

~/.Xresources:
URxvt.perl-lib: ENV_HOME/.urxvt/perl

best ... khay
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum