summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRené 'Necoro' Neumann <necoro@necoro.eu>2020-02-17 23:37:14 +0100
committerRené 'Necoro' Neumann <necoro@necoro.eu>2020-02-17 23:37:14 +0100
commit813e2b7e357b20a7807bed474237e7a1caf8468f (patch)
treee77aab52e1d4fd26cce3704c377e007f53bc4249
parentfb3dc5ec44ca5808380fee2f57cebd3acc018451 (diff)
downloaddotfiles-813e2b7e357b20a7807bed474237e7a1caf8468f.tar.gz
dotfiles-813e2b7e357b20a7807bed474237e7a1caf8468f.tar.bz2
dotfiles-813e2b7e357b20a7807bed474237e7a1caf8468f.zip
Update urxvt extension config
-rw-r--r--.Xresources9
-rw-r--r--.urxvt/extensions/clipboard115
2 files changed, 120 insertions, 4 deletions
diff --git a/.Xresources b/.Xresources
index 95d3c8d..cb2da32 100644
--- a/.Xresources
+++ b/.Xresources
@@ -25,7 +25,7 @@ URxvt.keysym.Shift-Down: command:\033]721;1\007
! perl-modules
URxvt.perl-lib: HOME/.urxvt/extensions/
-URxvt.perl-ext-common: default,url-select,clipboard,selection-autotransform,cwd-spawn
+URxvt.perl-ext-common: default,matcher,clipboard,selection-autotransform,cwd-spawn
! allow Alt-V/-C for pasting from/copying to clipboard
URxvt.keysym.M-v: perl:clipboard:paste
@@ -35,9 +35,10 @@ URxvt.keysym.M-c: perl:clipboard:copy
URxvt.keysym.M-Return: perl:cwd-spawn
! url-select via M-u
-URxvt.url-select.launcher: HOME/bin/openlink
-URxvt.keysym.M-u: perl:url-select:select_next
-URxvt.url-select.underline: true
+URxvt.url-launcher: HOME/bin/openlink
+URxvt.keysym.M-u: matcher:select
+URxvt.keysym.C-u: matcher:last
+URxvt.keysym.M-C-u: matcher:list
! transform selections of <filename>:<line> into a vim cmdline
URxvt.selection-autotransform.0: s/^([^:[:space:]]+):(\\d+):?$/vim +$2 \\Q$1\\E\\x0d/
diff --git a/.urxvt/extensions/clipboard b/.urxvt/extensions/clipboard
new file mode 100644
index 0000000..05e1601
--- /dev/null
+++ b/.urxvt/extensions/clipboard
@@ -0,0 +1,115 @@
+#! perl -w
+# Author: Bert Muennich
+# Website: http://www.github.com/muennich/urxvt-perls
+# License: GPLv2
+
+# Use keyboard shortcuts to copy the selection to the clipboard and to paste
+# the clipboard contents (optionally escaping all special characters).
+# Requires xsel to be installed!
+
+# Usage: put the following lines in your .Xdefaults/.Xresources:
+# URxvt.perl-ext-common: ...,clipboard
+# URxvt.keysym.M-c: perl:clipboard:copy
+# URxvt.keysym.M-v: perl:clipboard:paste
+# URxvt.keysym.M-C-v: perl:clipboard:paste_escaped
+
+# Options:
+# URxvt.clipboard.autocopy: If true, PRIMARY overwrites clipboard
+
+# You can also overwrite the system commands to use for copying/pasting.
+# The default ones are:
+# URxvt.clipboard.copycmd: xsel -ib
+# URxvt.clipboard.pastecmd: xsel -ob
+# If you prefer xclip, then put these lines in your .Xdefaults/.Xresources:
+# URxvt.clipboard.copycmd: xclip -i -selection clipboard
+# URxvt.clipboard.pastecmd: xclip -o -selection clipboard
+# On Mac OS X, put these lines in your .Xdefaults/.Xresources:
+# URxvt.clipboard.copycmd: pbcopy
+# URxvt.clipboard.pastecmd: pbpaste
+
+# The use of the functions should be self-explanatory!
+
+use strict;
+
+sub on_start {
+ my ($self) = @_;
+
+ $self->{copy_cmd} = $self->x_resource('clipboard.copycmd') || 'xsel -ib';
+ $self->{paste_cmd} = $self->x_resource('clipboard.pastecmd') || 'xsel -ob';
+
+ if ($self->x_resource('clipboard.autocopy') eq 'true') {
+ $self->enable(sel_grab => \&sel_grab);
+ }
+
+ ()
+}
+
+sub copy {
+ my ($self) = @_;
+
+ if (open(CLIPBOARD, "| $self->{copy_cmd}")) {
+ my $sel = $self->selection();
+ utf8::encode($sel);
+ print CLIPBOARD $sel;
+ close(CLIPBOARD);
+ } else {
+ print STDERR "error running '$self->{copy_cmd}': $!\n";
+ }
+
+ ()
+}
+
+sub paste {
+ my ($self) = @_;
+
+ my $str = `$self->{paste_cmd}`;
+ if ($? == 0) {
+ $self->tt_paste($str);
+ } else {
+ print STDERR "error running '$self->{paste_cmd}': $!\n";
+ }
+
+ ()
+}
+
+sub paste_escaped {
+ my ($self) = @_;
+
+ my $str = `$self->{paste_cmd}`;
+ if ($? == 0) {
+ $str =~ s/([!#\$%&\*\(\) ='"\\\|\[\]`~,<>\?])/\\\1/g;
+ $self->tt_paste($str);
+ } else {
+ print STDERR "error running '$self->{paste_cmd}': $!\n";
+ }
+
+ ()
+}
+
+sub on_action {
+ my ($self, $action) = @_;
+
+ on_user_command($self, "clipboard:" . $action);
+}
+
+sub on_user_command {
+ my ($self, $cmd) = @_;
+
+ if ($cmd eq "clipboard:copy") {
+ $self->copy;
+ } elsif ($cmd eq "clipboard:paste") {
+ $self->paste;
+ } elsif ($cmd eq "clipboard:paste_escaped") {
+ $self->paste_escaped;
+ }
+
+ ()
+}
+
+sub sel_grab {
+ my ($self) = @_;
+
+ $self->copy;
+
+ ()
+}