Skip to content

Instantly share code, notes, and snippets.

@xkr47
Created October 6, 2015 11:45
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xkr47/98224ed6b0860cb55ec0 to your computer and use it in GitHub Desktop.
Save xkr47/98224ed6b0860cb55ec0 to your computer and use it in GitHub Desktop.
rxvt-unicode: Enable Ctrl-Insert/Ctrl-Shift-c to copy to CLIPBOARD (as opposed to PRIMARY) selection. Pasting works by Meta-<middle button>
#! perl
# Store this file as /usr/lib/urxvt/perl/xkr-clipboard
#
# To enable, add to ~/.Xresources:
#
# URxvt.perl-ext-common: default,xkr-clipboard
# URxvt.iso14755: false
# URxvt.keysym.Shift-Control-C: perl:clipboard:copy
# URxvt.keysym.Control-Insert: perl:clipboard:copy
#
# Based on
# https://wiki.archlinux.org/index.php/Rxvt-unicode#Custom_key_bindings
# rxvt-unicode-9.19 / src/perl/clipboard-osc
sub on_user_command {
my ($self, $osc, $resp) = @_;
return unless $osc =~ s/^clipboard:([^;]+)//;
if ($1 eq "copy") {
my $text = $self->selection ();
$self->selection ($text, 1);
$self->selection_grab (urxvt::CurrentTime, 1);
}
1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment