]> git.99rst.org Git - irssi-scripts.irssi.org.git/commitdiff
Make the url color configurable
authorStefan Heinemann <redacted>
Tue, 3 Apr 2018 08:23:02 +0000 (10:23 +0200)
committerStefan Heinemann <redacted>
Tue, 3 Apr 2018 08:23:18 +0000 (10:23 +0200)
scripts/hilite_url.pl

index 11c4b0d936039ebb1f7a59f38707ca3048c05515..8a70dc66af00f2698f02807b50fac1eebd37ecbd 100644 (file)
@@ -1,24 +1,35 @@
-# Simple script to highlight links in public messages
+# Simple script to highlight urls
+# To configure the color, the setting 'url_color' can be set. The format
+# is like the bash colors. So for instance, if you want to have the links to be
+# colored in red, set the color to 31.
+# See this page for more information about colors:
+# https://misc.flogisoft.com/bash/tip_colors_and_formatting
 
 use strict;
+use Irssi;
 use vars qw($VERSION %IRSSI);
 
 # Dev. info ^_^
-$VERSION = "0.1";
+$VERSION = "0.2";
 %IRSSI = (
        authors     => "Stefan Heinemann",
        contact     => "stefan.heinemann\@codedump.ch",
-       name        => "hilite url",
-       description => "Simple script that highlights URL",
+       name        => "HiliteUrl",
+       description => "Simple script that highlights links",
        license     => "GPL",
        url         => "http://senseless.codedump.ch",
 );
 
+# All the works
 sub hilite_url {
        my ($server, $data, $nick, $mask, $target) = @_;
 
+       my $color = Irssi::settings_get_int('url_color');
+
+       $color = sprintf("\e[%sm", $color);
+
        # Add Colours
-       $data =~ s/(https?:\/\/[^\s]+)/\e[4;34m\1\e[00m/g;
+    $data =~ s/(https?:\/\/[^\s]+)/$color\1\e[00m/g;
 
        # Let it flow
        Irssi::signal_continue($server, $data, $nick, $mask, $target);
@@ -26,3 +37,7 @@ sub hilite_url {
 
 # Hook me up
 Irssi::signal_add('message public', 'hilite_url');
+
+Irssi::settings_add_int(
+       'hilite_url', 'url_color', "4;34"
+)
git clone https://git.99rst.org/PROJECT