View previous topic :: View next topic |
Author |
Message |
frankenputer n00b
Joined: 09 Mar 2016 Posts: 26
|
Posted: Thu Jun 30, 2016 11:23 am Post subject: [HOWTO] Copy and Paste in urxvt with custom bindings |
|
|
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 |
|
|
khayyam Watchman
Joined: 07 Jun 2012 Posts: 6227 Location: Room 101
|
Posted: Thu Jun 30, 2016 2:34 pm Post subject: Re: [HOWTO] Copy and Paste in urxvt with custom bindings |
|
|
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 |
|
|
|
|
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
|
|