From 35f46bb0515352c71d81d5ec13b51f96f2b8f9ef Mon Sep 17 00:00:00 2001 From: Tom Feist Date: Thu, 16 Sep 2010 15:08:25 +0100 Subject: added a script to tab-complete URIs into their tinified equivalents --- tinyurl-tabcomplete/complete-tiny-url.pl | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 tinyurl-tabcomplete/complete-tiny-url.pl (limited to 'tinyurl-tabcomplete/complete-tiny-url.pl') diff --git a/tinyurl-tabcomplete/complete-tiny-url.pl b/tinyurl-tabcomplete/complete-tiny-url.pl new file mode 100644 index 0000000..def9440 --- /dev/null +++ b/tinyurl-tabcomplete/complete-tiny-url.pl @@ -0,0 +1,29 @@ +use strict; +use vars qw($VERSION %IRSSI); + +use Irssi; +use Regexp::Common qw/URI/; +use WWW::Shorten::TinyURL; + +$VERSION = '2.1'; +%IRSSI = ( + authors => 'Shabble', + contact => 'shabble+irssi /at/ metavore /dot/ org', + name => 'Shorten URLs using Tab', + description => '', + license => 'WTFPL', +); + +sub do_complete { + my ($strings, $window, $word, $linestart, $want_space) = @_; + return if $word eq ''; + if ($word =~ m/$RE{URI}{HTTP}{-keep}/) { + my $uri = makeashorterlink($1); + push @$strings, $uri if $uri; + $$want_space = 1; + Irssi::signal_stop(); + } +} + +Irssi::signal_add_first( 'complete word', \&do_complete); + -- cgit v1.2.3