From: elmex Date: Tue, 17 Jan 2006 13:19:45 +0000 (+0000) Subject: documented and improved remote-pastebin. X-Git-Url: http://git.openbox.org/?a=commitdiff_plain;h=797e14c522ac9025aa042565d07828dbe46b5032;p=dana%2Furxvt.git documented and improved remote-pastebin. --- diff --git a/src/perl/selection b/src/perl/selection index c090e7e9..a87c6d67 100644 --- a/src/perl/selection +++ b/src/perl/selection @@ -21,27 +21,32 @@ sub upload_paste { my ($self) = @_; my $txt = $self->selection; - my $h = md5_hex ($txt); + my $filename = md5_hex ($txt) . ".txt"; - my $fn = "/tmp/$h.txt"; + my $tmpfile = "/tmp/$filename"; - my $msg = "uploaded $h.txt"; + my $msg = "uploaded $filename"; - if (open my $o, ">" . $fn) { + if (open my $o, ">" . $tmpfile) { print $o $txt; close $o; } else { - $msg = "couldn't write $fn: $!"; + $msg = "couldn't write $tmpfile: $!"; } my $cmd = $pastebin_cmd; - $cmd =~ s/%/$fn/; - unless (system ($cmd) == 0) { + $cmd =~ s/%/$tmpfile/; + + if (system ($cmd) == 0) { + + my $url = $pastebin_url; + $url =~ s/%/$filename/; + + $self->selection ($url); + } else { $msg = "couldn't upload, '$cmd' failed"; } - $self->selection ($pastebin_url . "$h.txt"); - my $ov = $timers->{ov} = $self->overlay (-1, 0, length ($msg), 1, urxvt::OVERLAY_RSTYLE, 0); $ov->set (0, 0, $msg); diff --git a/src/urxvt.pm b/src/urxvt.pm index 8d9c98e6..368a3dae 100644 --- a/src/urxvt.pm +++ b/src/urxvt.pm @@ -68,7 +68,7 @@ between two vertical bars: You can look at the source of the selection extension to see more interesting uses, such as parsing a line from beginning to end. -This extension also offers the following bindable keyboard command: +This extension also offers following bindable keyboard commands: =over 4 @@ -78,6 +78,23 @@ Rot-13 the selection when activated. Used via keyboard trigger: URxvt.keysym.C-M-r: perl:selection:rot13 +=item remote-pastebin + +Upload the selection as textfile to a remote site. + + URxvt.keysym.C-M-e: perl:selection:remote-pastebin + +To set the command to upload the file set this resource: + + URxvt.selection-pastebin-cmd: rsync -apP % ruth:/var/www/www.ta-sa.org/files/txt/. + +The % is the placeholder for the textfile. The name of the textfile is the hex encoded +md5 sum of the selection. +After an successful upload the selection will be replaced by the following url +(the % is the placeholder for the filename): + + URxvt.selection-pastebin-url: http://www.ta-sa.org/files/txt/% + =back =item option-popup (enabled by default)