#! perl # same url as used in "selection" my $url = qr{( (?:https?|ftp|news|mailto|file)://[ab-zA-Z0-9\-\@;\/?:&=%\$_.+!*\x27(),~]+ [ab-zA-Z0-9\-\@;\/?:&=%\$_+!*\x27(),~] # do not include a trailing dot, its wrong too often )}x; sub on_line_update { my ($term, $row) = @_; # fetch the line that has changed my $line = $term->line ($row); my $text = $line->t; # find all urls (if any) while ($text =~ /$url/g) { my $rend = $line->r; # mark all characters as underlined. we _must_ not toggle underline, # as we might get called on an already-marked url. $_ |= urxvt::RS_Uline for @{$rend}[ $-[1] .. $+[1] - 1]; $line->r ($rend); } () }