Added irssi configs.

This commit is contained in:
Darren 'Tadgy' Austin 2020-07-02 05:06:35 +01:00
commit 6ccf0f6efa
8 changed files with 1239 additions and 0 deletions

1
.irssi/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
config

BIN
.irssi/config.gpg Normal file

Binary file not shown.

314
.irssi/default.theme Normal file
View file

@ -0,0 +1,314 @@
# When testing changes, the easiest way to reload the theme is with /RELOAD.
# This reloads the configuration file too, so if you did any changes remember
# to /SAVE it first. Remember also that /SAVE overwrites the theme file with
# old data so keep backups :)
# TEMPLATES:
# The real text formats that irssi uses are the ones you can find with
# /FORMAT command. Back in the old days all the colors and texts were mixed
# up in those formats, and it was really hard to change the colors since you
# might have had to change them in tens of different places. So, then came
# this templating system.
# Now the /FORMATs don't have any colors in them, and they also have very
# little other styling. Most of the stuff you need to change is in this
# theme file. If you can't change something here, you can always go back
# to change the /FORMATs directly, they're also saved in these .theme files.
# So .. the templates. They're those {blahblah} parts you see all over the
# /FORMATs and here. Their usage is simply {name parameter1 parameter2}.
# When irssi sees this kind of text, it goes to find "name" from abstracts
# block below and sets "parameter1" into $0 and "parameter2" into $1 (you
# can have more parameters of course). Templates can have subtemplates.
# Here's a small example:
# /FORMAT format hello {colorify {underline world}}
# abstracts = { colorify = "%G$0-%n"; underline = "%U$0-%U"; }
# When irssi expands the templates in "format", the final string would be:
# hello %G%Uworld%U%n
# ie. underlined bright green "world" text.
# and why "$0-", why not "$0"? $0 would only mean the first parameter,
# $0- means all the parameters. With {underline hello world} you'd really
# want to underline both of the words, not just the hello (and world would
# actually be removed entirely).
# COLORS:
# text text background
# ---------------------------------------------------------------------
# %k %K %0 black bold black black
# %r %R %1 red bold red red
# %g %G %2 green bold green green
# %y %Y %3 yellow bold yellow yellow
# %b %B %4 blue bold blue blue
# %m %M %5 magenta bold magenta magenta
# %p %P magenta (think: purple)
# %c %C %6 cyan bold cyan cyan
# %w %W %7 white bold white white
# %n %N Turn off all colors and other formatting
# %F Blinking on/off (think: flash)
# %U Underline on/off
# %8 Reverse on/off
# %9 %_ Bold on/off
# %: Insert newline
# %| Marks the indentation position
# %% A single %
# There's one difference here though. %n format. Normally it means the
# default color of the terminal (white mostly), but here it means the
# "reset color back to the one it was in higher template". For example
# if there was /FORMAT test %g{foo}bar, and foo = "%Y$0%n", irssi would
# print yellow "foo" (as set with %Y) but "bar" would be green, which was
# set at the beginning before the {foo} template. If there wasn't the %g
# at start, the normal behaviour of %n would occur. If you _really_ want
# to use the terminal's default color, use %N.
#############################################################################
# default foreground color (%N) - -1 is the "default terminal color"
default_color = "-1";
# print timestamp/servertag at the end of line, not at beginning
info_eol = "false";
# these characters are automatically replaced with specified color
# (dark grey by default)
replaces = { "[]=" = "%K$*%n"; };
abstracts = {
##
## generic
##
# text to insert at the beginning of each non-message line
line_start = "%B-%W!%B-%n ";
# timestamp styling
timestamp = "%K$*%n";
# any kind of text that needs hilighting, default is to bold
hilight = "%_$*%_";
# any kind of error message, default is bright red
error = "%R$*%n";
# channel name is printed
channel = "%_$*%_";
# nick is printed
nick = "%_$*%_";
# nick host is printed
nickhost = "[$*]";
# server name is printed
server = "%_$*%_";
# some kind of comment is printed
comment = "[$*]";
# reason for something is printed (part, quit, kick, ..)
reason = "{comment $*}";
# mode change is printed ([+o nick])
mode = "{comment $*}";
##
## channel specific messages
##
# highlighted nick/host is printed (joins)
channick_hilight = "%C$*%n";
chanhost_hilight = "{nickhost %c$*%n}";
# nick/host is printed (parts, quits, etc.)
channick = "%c$*%n";
chanhost = "{nickhost $*}";
# highlighted channel name is printed
channelhilight = "%c$*%n";
# ban/ban exception/invite list mask is printed
ban = "%c$*%n";
##
## messages
##
# the basic styling of how to print message, $0 = nick mode, $1 = nick
msgnick = "%K<%n$0$1-%K>%n %|";
# message from you is printed. "msgownnick" specifies the styling of the
# nick ($0 part in msgnick) and "ownmsgnick" specifies the styling of the
# whole line.
# Example1: You want the message text to be green:
# ownmsgnick = "{msgnick $0 $1-}%g";
# Example2.1: You want < and > chars to be yellow:
# ownmsgnick = "%Y{msgnick $0 $1-%Y}%n";
# (you'll also have to remove <> from replaces list above)
# Example2.2: But you still want to keep <> grey for other messages:
# pubmsgnick = "%K{msgnick $0 $1-%K}%n";
# pubmsgmenick = "%K{msgnick $0 $1-%K}%n";
# pubmsghinick = "%K{msgnick $1 $0$2-%n%K}%n";
# ownprivmsgnick = "%K{msgnick $*%K}%n";
# privmsgnick = "%K{msgnick %R$*%K}%n";
# $0 = nick mode, $1 = nick
ownmsgnick = "{msgnick $0 $1-}";
ownnick = "%_$*%n";
# public message in channel, $0 = nick mode, $1 = nick
pubmsgnick = "{msgnick $0 $1-}";
pubnick = "%N$*%n";
# public message in channel meant for me, $0 = nick mode, $1 = nick
pubmsgmenick = "{msgnick $0 $1-}";
menick = "%Y$*%n";
# public highlighted message in channel
# $0 = highlight color, $1 = nick mode, $2 = nick
pubmsghinick = "{msgnick $1 $0$2-%n}";
# channel name is printed with message
msgchannel = "%K:%c$*%n";
# private message, $0 = nick, $1 = host
privmsg = "[%R$0%K(%r$1-%K)%n] ";
# private message from you, $0 = "msg", $1 = target nick
ownprivmsg = "[%r$0%K(%R$1-%K)%n] ";
# own private message in query
ownprivmsgnick = "{msgnick $*}";
ownprivnick = "%_$*%n";
# private message in query
privmsgnick = "{msgnick %R$*%n}";
##
## Actions (/ME stuff)
##
# used internally by this theme
action_core = "%_ * $*%n";
# generic one that's used by most actions
action = "{action_core $*} ";
# own action, both private/public
ownaction = "{action $*}";
# own action with target, both private/public
ownaction_target = "{action_core $0}%K:%c$1%n ";
# private action sent by others
pvtaction = "%_ (*) $*%n ";
pvtaction_query = "{action $*}";
# public action sent by others
pubaction = "{action $*}";
##
## other IRC events
##
# whois
whois = "%# $[8]0 : $1-";
# notices
ownnotice = "[%r$0%K(%R$1-%K)]%n ";
notice = "%K-%B$*%K-%n ";
pubnotice_channel = "%K:%m$*";
pvtnotice_host = "%K(%m$*%K)";
servernotice = "%g!$*%n ";
# CTCPs
ownctcp = "[%r$0%K(%R$1-%K)] ";
ctcp = "%g$*%n";
# wallops
wallop = "%_$*%n: ";
wallop_nick = "%n$*";
wallop_action = "%_ * $*%n ";
# netsplits
netsplit = "%R$*%n";
netjoin = "%C$*%n";
# /names list
names_prefix = "";
names_nick = "[%_$0%_$1-] ";
names_nick_op = "{names_nick $*}";
names_nick_halfop = "{names_nick $*}";
names_nick_voice = "{names_nick $*}";
names_users = "[%g$*%n]";
names_channel = "%G$*%n";
# DCC
dcc = "%g$*%n";
dccfile = "%_$*%_";
# DCC chat, own msg/action
dccownmsg = "[%r$0%K($1-%K)%n] ";
dccownnick = "%R$*%n";
dccownquerynick = "%_$*%n";
dccownaction = "{action $*}";
dccownaction_target = "{action_core $0}%K:%c$1%n ";
# DCC chat, others
dccmsg = "[%G$1-%K(%g$0%K)%n] ";
dccquerynick = "%G$*%n";
dccaction = "%_ (*dcc*) $*%n %|";
##
## statusbar
##
# default background for all statusbars. You can also give
# the default foreground color for statusbar items.
sb_background = "%0%K";
sbpadding = "----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------";
# default backround for "default" statusbar group
#sb_default_bg = "%4";
# background for prompt / input line
sb_prompt_bg = "%n";
# background for info statusbar
sb_info_bg = "%8";
# background for topicbar (same default)
#sb_topic_bg = "%4";
# text at the beginning of statusbars. sb-item already puts
# space there,so we don't use anything by default.
sbstart = "";
# text at the end of statusbars. Use space so that it's never
# used for anything.
sbend = "";
topicsbstart = "{sbstart $*}";
topicsbend = "{sbend $*}";
prompt = "[$*] ";
sb = "----[%w$*%K]";
sbmode = "%K(+%w$*%K)";
sbaway = "----[%GAway%K]%K";
sbservertag = ":%w$0%K (change with ^X)";
sbnickmode = "$0";
# activity in statusbar
# ',' separator
sb_act_sep = "%K$* ";
# normal text
sb_act_text = "%K$*";
# public message
sb_act_msg = "%W$*%K";
# hilight
sb_act_hilight = "%G$*";
# hilight with specified color, $0 = color, $1 = text
sb_act_hilight_color = "$0$1-%n";
};
formats = { "fe-common/core" = { daychange = ""; }; };

295
.irssi/default.theme.purple Normal file
View file

@ -0,0 +1,295 @@
# When testing changes, the easiest way to reload the theme is with /RELOAD.
# This reloads the configuration file too, so if you did any changes remember
# to /SAVE it first. Remember also that /SAVE overwrites the theme file with
# old data so keep backups :)
# TEMPLATES:
# The real text formats that irssi uses are the ones you can find with
# /FORMAT command. Back in the old days all the colors and texts were mixed
# up in those formats, and it was really hard to change the colors since you
# might have had to change them in tens of different places. So, then came
# this templating system.
# Now the /FORMATs don't have any colors in them, and they also have very
# little other styling. Most of the stuff you need to change is in this
# theme file. If you can't change something here, you can always go back
# to change the /FORMATs directly, they're also saved in these .theme files.
# So .. the templates. They're those {blahblah} parts you see all over the
# /FORMATs and here. Their usage is simply {name parameter1 parameter2}.
# When irssi sees this kind of text, it goes to find "name" from abstracts
# block below and sets "parameter1" into $0 and "parameter2" into $1 (you
# can have more parameters of course). Templates can have subtemplates.
# Here's a small example:
# /FORMAT format hello {colorify {underline world}}
# abstracts = { colorify = "%G$0-%n"; underline = "%U$0-%U"; }
# When irssi expands the templates in "format", the final string would be:
# hello %G%Uworld%U%n
# ie. underlined bright green "world" text.
# and why "$0-", why not "$0"? $0 would only mean the first parameter,
# $0- means all the parameters. With {underline hello world} you'd really
# want to underline both of the words, not just the hello (and world would
# actually be removed entirely).
# COLORS:
# You can find definitions for the color format codes in docs/formats.txt.
# There's one difference here though. %n format. Normally it means the
# default color of the terminal (white mostly), but here it means the
# "reset color back to the one it was in higher template". For example
# if there was /FORMAT test %g{foo}bar, and foo = "%Y$0%n", irssi would
# print yellow "foo" (as set with %Y) but "bar" would be green, which was
# set at the beginning before the {foo} template. If there wasn't the %g
# at start, the normal behaviour of %n would occur. If you _really_ want
# to use the terminal's default color, use %N.
#############################################################################
# default foreground color (%N) - -1 is the "default terminal color"
default_color = "-1";
# print timestamp/servertag at the end of line, not at beginning
info_eol = "false";
# these characters are automatically replaced with specified color
# (dark grey by default)
replaces = { "[]=" = "%K$*%n"; };
abstracts = {
##
## generic
##
# text to insert at the beginning of each non-message line
line_start = "%B-%n!%B-%n ";
# timestamp styling, nothing by default
timestamp = "$*";
# any kind of text that needs hilighting, default is to bold
hilight = "%_$*%_";
# any kind of error message, default is bright red
error = "%R$*%n";
# channel name is printed
channel = "%_$*%_";
# nick is printed
nick = "%_$*%_";
# nick host is printed
nickhost = "[$*]";
# server name is printed
server = "%_$*%_";
# some kind of comment is printed
comment = "[$*]";
# reason for something is printed (part, quit, kick, ..)
reason = "{comment $*}";
# mode change is printed ([+o nick])
mode = "{comment $*}";
##
## channel specific messages
##
# highlighted nick/host is printed (joins)
channick_hilight = "%C$*%n";
chanhost_hilight = "{nickhost %c$*%n}";
# nick/host is printed (parts, quits, etc.)
channick = "%c$*%n";
chanhost = "{nickhost $*}";
# highlighted channel name is printed
channelhilight = "%c$*%n";
# ban/ban exception/invite list mask is printed
ban = "%c$*%n";
##
## messages
##
# the basic styling of how to print message, $0 = nick mode, $1 = nick
msgnick = "%K<%n$0$1-%K>%n %|";
# message from you is printed. "msgownnick" specifies the styling of the
# nick ($0 part in msgnick) and "ownmsgnick" specifies the styling of the
# whole line.
# Example1: You want the message text to be green:
# ownmsgnick = "{msgnick $0 $1-}%g";
# Example2.1: You want < and > chars to be yellow:
# ownmsgnick = "%Y{msgnick $0 $1-%Y}%n";
# (you'll also have to remove <> from replaces list above)
# Example2.2: But you still want to keep <> grey for other messages:
# pubmsgnick = "%K{msgnick $0 $1-%K}%n";
# pubmsgmenick = "%K{msgnick $0 $1-%K}%n";
# pubmsghinick = "%K{msgnick $1 $0$2-%n%K}%n";
# ownprivmsgnick = "%K{msgnick $*%K}%n";
# privmsgnick = "%K{msgnick %R$*%K}%n";
# $0 = nick mode, $1 = nick
ownmsgnick = "{msgnick $0 $1-}";
ownnick = "%_$*%n";
# public message in channel, $0 = nick mode, $1 = nick
pubmsgnick = "{msgnick $0 $1-}";
pubnick = "%N$*%n";
# public message in channel meant for me, $0 = nick mode, $1 = nick
pubmsgmenick = "{msgnick $0 $1-}";
menick = "%Y$*%n";
# public highlighted message in channel
# $0 = highlight color, $1 = nick mode, $2 = nick
pubmsghinick = "{msgnick $1 $0$2-%n}";
# channel name is printed with message
msgchannel = "%K:%c$*%n";
# private message, $0 = nick, $1 = host
privmsg = "[%R$0%K(%r$1-%K)%n] ";
# private message from you, $0 = "msg", $1 = target nick
ownprivmsg = "[%r$0%K(%R$1-%K)%n] ";
# own private message in query
ownprivmsgnick = "{msgnick $*}";
ownprivnick = "%_$*%n";
# private message in query
privmsgnick = "{msgnick %R$*%n}";
##
## Actions (/ME stuff)
##
# used internally by this theme
action_core = "%_ * $*%n";
# generic one that's used by most actions
action = "{action_core $*} ";
# own action, both private/public
ownaction = "{action $*}";
# own action with target, both private/public
ownaction_target = "{action_core $0}%K:%c$1%n ";
# private action sent by others
pvtaction = "%_ (*) $*%n ";
pvtaction_query = "{action $*}";
# public action sent by others
pubaction = "{action $*}";
##
## other IRC events
##
# whois
whois = "%# $[8]0 : $1-";
# notices
ownnotice = "[%r$0%K(%R$1-%K)]%n ";
notice = "%K-%B$*%K-%n ";
pubnotice_channel = "%K:%m$*";
pvtnotice_host = "%K(%m$*%K)";
servernotice = "%g!$*%n ";
# CTCPs
ownctcp = "[%r$0%K(%R$1-%K)] ";
ctcp = "%g$*%n";
# wallops
wallop = "%_$*%n: ";
wallop_nick = "%n$*";
wallop_action = "%_ * $*%n ";
# netsplits
netsplit = "%R$*%n";
netjoin = "%C$*%n";
# /names list
names_prefix = "";
names_nick = "[%_$0%_$1-] ";
names_nick_op = "{names_nick $*}";
names_nick_halfop = "{names_nick $*}";
names_nick_voice = "{names_nick $*}";
names_users = "[%g$*%n]";
names_channel = "%G$*%n";
# DCC
dcc = "%g$*%n";
dccfile = "%_$*%_";
# DCC chat, own msg/action
dccownmsg = "[%r$0%K($1-%K)%n] ";
dccownnick = "%R$*%n";
dccownquerynick = "%_$*%n";
dccownaction = "{action $*}";
dccownaction_target = "{action_core $0}%K:%c$1%n ";
# DCC chat, others
dccmsg = "[%G$1-%K(%g$0%K)%n] ";
dccquerynick = "%G$*%n";
dccaction = "%_ (*dcc*) $*%n %|";
##
## statusbar
##
# default background for all statusbars. You can also give
# the default foreground color for statusbar items.
sb_background = "%5%w";
# default backround for "default" statusbar group
#sb_default_bg = "%4";
# background for prompt / input line
sb_prompt_bg = "%n";
# background for info statusbar
sb_info_bg = "%8";
# background for topicbar (same default)
#sb_topic_bg = "%4";
# text at the beginning of statusbars. sb-item already puts
# space there,so we don't use anything by default.
sbstart = "";
# text at the end of statusbars. Use space so that it's never
# used for anything.
sbend = " ";
topicsbstart = "{sbstart $*}";
topicsbend = "{sbend $*}";
prompt = "[$*] ";
sb = " %c[%n$*%c]%n";
sbmode = "(%c+%n$*)";
sbaway = " (%GzZzZ%n)";
sbservertag = ":$0 (change with ^X)";
sbnickmode = "$0";
# activity in statusbar
# ',' separator
sb_act_sep = "%c$*";
# normal text
sb_act_text = "%c$*";
# public message
sb_act_msg = "%W$*";
# hilight
sb_act_hilight = "%B$*";
# hilight with specified color, $0 = color, $1 = text
sb_act_hilight_color = "$0$1-%n";
};
formats = { "fe-common/core" = { daychange = ""; }; };

View file

@ -0,0 +1,39 @@
# /WHOIS all the users who send you a private message.
# v1.1 for irssi 0.7.98 by Timo Sirainen
use strict;
use Irssi;
use vars qw($VERSION %IRSSI);
$VERSION = "1.1";
%IRSSI = (
authors => "Timo \'cras\' Sirainen",
contact => "tss\@iki.fi",
name => "autowhois",
description => "/WHOIS all the users who send you a private message.",
license => "Public Domain",
url => "http://irssi.org/",
changed => "2002-03-04T22:47+0100",
changes => "v1.1: don't /WHOIS if query exists for the nick already"
);
# History:
# v1.1: don't /WHOIS if query exists for the nick already
my ($lastfrom, $lastquery);
sub msg_private_first {
my ($server, $msg, $nick, $address) = @_;
$lastquery = $server->query_find($nick);
}
sub msg_private {
my ($server, $msg, $nick, $address) = @_;
return if $lastquery || $lastfrom eq $nick;
$lastfrom = $nick;
$server->command("whois $nick");
}
Irssi::signal_add_first('message private', 'msg_private_first');
Irssi::signal_add('message private', 'msg_private');

189
.irssi/scripts/trackbar.pl Normal file
View file

@ -0,0 +1,189 @@
# trackbar.pl
#
# This little script will do just one thing: it will draw a line each time you
# switch away from a window. This way, you always know just upto where you've
# been reading that window :) It also removes the previous drawn line, so you
# don't see double lines.
#
# Usage:
#
# The script works right out of the box, but if you want you can change
# the working by /set'ing the following variables:
#
# trackbar_string The characters to repeat to draw the bar
# trackbar_style The style for the bar, %r is red for example
# See formats.txt that came with irssi
#
# /mark is a command that will redraw the line at the bottom. However! This
# requires irssi version after 20021228. otherwise you'll get the error
# redraw: unknown command, and your screen is all goofed up :)
#
# /upgrade & buf.pl notice: This version tries to remove the trackbars before
# the upgrade is done, so buf.pl does not restore them, as they are not removeable
# afterwards by trackbar. Unfortiounatly, to make this work, trackbar and buf.pl
# need to be loaded in a specific order. Please experiment to see which order works
# for you (strangely, it differs from configuration to configuration, something I will
# try to fix in a next version)
#
# Authors:
# - Main maintainer & author: Peter 'kinlo' Leurs
# - Many thanks to Timo 'cras' Sirainen for placing me on my way
# - on-upgrade-remove-line patch by Uwe Dudenhoeffer
#
# Version history:
# 1.4: - Changed our's by my's so the irssi script header is valid
# - Removed utf-8 support. In theory, the script should work w/o any
# problems for utf-8, just set trackbar_string to a valid utf-8 character
# and everything *should* work. However, this script is being plagued by
# irssi internal bugs. The function Irssi::settings_get_str does NOT handle
# unicode strings properly, hence you will notice problems when setting the bar
# to a unicode char. For changing your bar to utf-8 symbols, read the line sub.
# 1.3: - Upgrade now removes the trackbars.
# - Some code cleanups, other defaults
# - /mark sets the line to the bottom
# 1.2: - Support for utf-8
# - How the bar looks can now be configured with trackbar_string
# and trackbar_style
# 1.1: - Fixed bug when closing window
# 1.0: - Initial release
#
#
# Call for help!
#
# There is a trackbar version 2.0 that properly handles resizes and immediate config change
# activation. However, there is/are some bug(s) in irssi's main buffer/window code that causes
# irssi to 'forget' lines, which is ofcourse completly unaccepteable. I haven't found the time
# nor do I know the irssi's internals enough to find and fix this bug, if you want to help, please
# contact me, I'll give you a copy of the 2.0 version that will immediatly show you the problems.
#
# Known bugs:
# - if you /clear a window, it will be uncleared when returning to the window
# - UTF-8 characters in the trackbar_string doesnt work. This is an irssi bug.
# - if you resize your irssi (in xterm or so) the bar is not resized
# - changing the trackbar style is only visible after returning to a window
# however, changing style/resize takes in effect after you left the window.
#
# Whishlist/todo:
# - instead of drawing a line, just invert timestamp or something,
# to save a line (but I don't think this is possible with current irssi)
# - some pageup keybinding possibility, to scroll up upto the trackbar
# - <@coekie> kinlo: if i switch to another window, in another split window, i
# want the trackbar to go down in the previouswindow in that splitwindow :)
# - < bob_2> anyway to clear the line once the window is read?
# - < elho> kinlo: wishlist item: a string that gets prepended to the repeating pattern
# - < elho> an option to still have the timestamp in front of the bar
# - < elho> oh and an option to not draw it in the status window :P
#
# BTW: when you have feature requests, mailing a patch that works is the fastest way
# to get it added :p
use strict;
use 5.6.1;
use Irssi;
use Irssi::TextUI;
my $VERSION = "1.4";
my %IRSSI = (
authors => "Peter 'kinlo' Leurs",
contact => "peter\@pfoe.be",
name => "trackbar",
description => "Shows a bar where you've last read a window",
license => "GPLv2",
url => "http://www.pfoe.be/~peter/trackbar/",
changed => "Thu Feb 20 16:18:08 2003",
);
my %config;
Irssi::settings_add_str('trackbar', 'trackbar_string' => '_');
$config{'trackbar_string'} = Irssi::settings_get_str('trackbar_string');
Irssi::settings_add_str('trackbar', 'trackbar_style' => '%K');
$config{'trackbar_style'} = Irssi::settings_get_str('trackbar_style');
Irssi::signal_add(
'setup changed' => sub {
$config{'trackbar_string'} = Irssi::settings_get_str('trackbar_string');
$config{'trackbar_style'} = Irssi::settings_get_str('trackbar_style');
if ($config{'trackbar_style'} =~ /(?<!%)[^%]|%%|%$/) {
Irssi::print(
"trackbar: %RWarning!%n 'trackbar_style' seems to contain "
. "printable characters. Only use format codes (read "
. "formats.txt).", MSGLEVEL_CLIENTERROR);
}
}
);
Irssi::signal_add(
'window changed' => sub {
my (undef, $oldwindow) = @_;
if ($oldwindow) {
my $line = $oldwindow->view()->get_bookmark('trackbar');
$oldwindow->view()->remove_line($line) if defined $line;
$oldwindow->print(line($oldwindow->{'width'}), MSGLEVEL_NEVER);
$oldwindow->view()->set_bookmark_bottom('trackbar');
}
}
);
sub line {
my $width = shift;
my $string = $config{'trackbar_string'};
$string = '-' unless defined $string;
# There is a bug in irssi's utf-8 handling on config file settings, as you
# can reproduce/see yourself by the following code sniplet:
#
# my $quake = pack 'U*', 8364; # EUR symbol
# Irssi::settings_add_str 'temp', 'temp_foo' => $quake;
# Irssi::print length $quake;
# # prints 1
# Irssi::print length Irssi::settings_get_str 'temp_foo';
# # prints 3
#
#
# Trackbar used to have a workaround, but on recent versions of perl/irssi
# it does no longer work. Therefore, if you want your trackbar to contain
# unicode characters, uncomment the line below for a nice full line, or set
# the string to whatever char you want.
# $string = pack('U*', 0x2500);
my $length = length $string;
if ($length == 0) {
$string = '-';
$length = 1;
}
my $times = $width / $length;
$times = int(1 + $times) if $times != int($times);
$string =~ s/%/%%/g;
return $config{'trackbar_style'} . substr($string x $times, 0, $width);
}
# Remove trackbars on upgrade - but this doesn't really work if the scripts are not loaded in the correct order... watch out!
Irssi::signal_add_first( 'session save' => sub {
for my $window (Irssi::windows) {
next unless defined $window;
my $line = $window->view()->get_bookmark('trackbar');
$window->view()->remove_line($line) if defined $line;
}
}
);
sub cmd_mark {
my $window = Irssi::active_win();
# return unless defined $window;
my $line = $window->view()->get_bookmark('trackbar');
$window->view()->remove_line($line) if defined $line;
$window->print(line($window->{'width'}), MSGLEVEL_NEVER);
$window->view()->set_bookmark_bottom('trackbar');
Irssi::command("redraw");
}
Irssi::command_bind('mark', 'cmd_mark');

View file

@ -0,0 +1,398 @@
#!/usr/bin/perl
#
# NOTE This script uses parts of the following 3 scripts, with modifications,
# and all their relevant licenses apply:
#
# name => 'urlgrab',
# authors => 'David Leadbeater',
# contact => 'dgl@dgl.cx',
# license => 'GNU GPLv2 or later',
#
# name => "HiliteUrl",
# authors => "Stefan Heinemann",
# contact => "stefan.heinemann\@codedump.ch",
# license => "GPL",
#
# name => "OpenURL",
# authors => "Stefan 'tommie' Tomanek",
# contact => "stefan\@pico.ruhr.de",
# license => "GPLv2",
#
# Settings:
#
# url_cmd
# Irssi command to execute to process URLs. %s is replaced by URL.
# Default: ^exec xdg-open '%s'
#
# colour_urls
# whether to colour URLs or not.
# Default: 1
#
# url_colour
#
# mirc colour, from:
#
# 0 white
# 1 black
# 2 blue
# 3 green
# 4 light red
# 5 red
# 6 magenta
# 7 orange
# 8 yellow orange
# 9 light green
# 10 cyan
# 11 light cyan
# 12 light blue
# 13 light magenta
# 14 gray
# 15 light gray
#
# Default: 3
#
# url_number_colour
# URL number colour as above.
# Default: 12
#
# max_urls
# Number at which URLs cycle back to 1.
# Default: 50
#
# Commands:
#
# /url <N> <#channel|refnum> Open a URL N using url_cmd. N<1: count
# back from end of log. Without N, opens
# last in current buffer or <#channel>.
#
# /list_urls <N> <#channel|refnum> Print last N URLs in log.
#
# /clear_urls Reset URL list in mem, but not log.
#
# refnum is the window number.
use strict;
use warnings;
use Irssi;
use vars qw($VERSION %IRSSI);
$VERSION = "1.0.0";
%IRSSI = (
authors => "dive",
contact => "dave\@tty1.uk",
name => "urlmachine2",
changed => "$VERSION",
commands => "url, list_urls, clear_urls",
description => "Logs and hilights URLs. Adds /url command to open them.",
license => "GPL, GNU GPLv2 or later, and BSD. See comments.",
url => "http://tty1.uk",
);
sub init {
Irssi::settings_add_str( "urlmachine", "url_cmd", "/^exec xdg-open '%s'" );
Irssi::settings_add_int( "urlmachine", "url_colour", "12" );
Irssi::settings_add_int( "urlmachine", "url_number_colour", "9" );
Irssi::settings_add_int( "urlmachine", "max_urls", 50 );
Irssi::settings_add_bool( "urlmachine", "colour_urls", 1 );
Irssi::settings_add_bool( "urlmachine", "debug_urls", 0 );
Irssi::command_bind( "url", "url_command" );
Irssi::command_bind( "list_urls", "list_urls" );
Irssi::command_bind( "clear_urls", "clear_urls" );
Irssi::signal_add_first( "message irc action", "url_public" );
Irssi::signal_add_first( "message irc own_action", 'hilite_urls' );
Irssi::signal_add_first( "message irc notice", "url_public" );
Irssi::signal_add_first( "message irc own_notice", 'hilite_urls' );
Irssi::signal_add_first( "message private", "url_private" );
Irssi::signal_add_first( "message own_private", 'hilite_urls' );
Irssi::signal_add_first( "message public", "url_public" );
Irssi::signal_add_first( "message own_public", 'hilite_urls' );
Irssi::signal_add_first( "channel topic changed", "hilite_topic" );
# Irssi::signal_add( "message topic", "hilite_topic" );
}
init();
my @urls;
my $lasturl = "";
# All protocols listed in https://www.ietf.org/rfc/rfc1738.txt + https
# It's far simpler to disallow unsafe characters than look for legitimate ones
# TODO Add support for www. etc.
# TODO protocol-specific commands with url_cmd as a default.
my $protocols = 'ftp|https?|git|gopher|mailto|news|nntp|rsync';
$protocols .= '|telnet|wais|file|prospero';
my $urlstr = '(' . $protocols . ')://[^\s<>"\'\017\003]+';
my $urlreg = qr{$urlstr}i;
sub hilite_topic {
my ($data) = @_;
my $server = $data->{server};
my $text = $data->{topic};
my $channel = $data->{name};
my $nick = $channel;
my $hostmask = "";
my $witem;
if ($text && $data->{topic_time} > 0) {
my @links = grep { /$urlreg/ } ( split /($urlreg)/i, $text );
if (@links) {
$text = parse_urls( $server, join ("\n", @links) , $nick, $hostmask, $channel );
if ($server) {
$witem = $server->window_item_find($channel);
}
else {
$witem = Irssi::window_item_find($channel);
}
if ($witem) {
$witem->print( $text, MSGLEVEL_CLIENTCRAP );
}
}
}
Irssi::signal_continue($data);
}
sub hilite_urls {
my ( $server, $text, $hostmask ) = @_;
if ( $text =~ /$urlreg/ && Irssi::settings_get_bool('colour_urls') ) {
my $ucolour =
sprintf( "\003%02d", Irssi::settings_get_int('url_colour') );
my $endcolour = sprintf( "%s", "\017" );
# Add Colours
$text =~ s`($urlreg)`$ucolour$1$endcolour`ig;
}
## Let it flow
Irssi::signal_continue( $server, $text, $hostmask );
}
sub find_urls {
my $text = shift;
my @links = grep { /$urlreg/ } ( split /($urlreg)/i, $text );
return @links if @links;
return ();
}
sub parse_urls {
my ( $server, $text, $nick, $hostmask, $channel ) = @_;
$server = $server->{tag};
my @links = find_urls($text);
return $text unless @links;
my $index;
my $ucolour =
sprintf( "\003%02d", Irssi::settings_get_int('url_colour') );
my $ncolour =
sprintf( "\003%02d", Irssi::settings_get_int('url_number_colour') );
my $endcolour = sprintf( "%s", "\017" );
if ( Irssi::settings_get_bool('colour_urls') ) {
$text =~ s`($urlreg)`$ucolour$1`ig;
}
foreach (@links) {
#debug_log("\$_: $_");
$index = url_log( $server, $channel, $nick, $_ );
return $text if $index == 0;
$text =~ s`\Q$_\E`$_ $ncolour\[$index\]$endcolour`;
}
return "$text";
}
sub url_public {
my ( $server, $text, $nick, $hostmask, $channel ) = @_;
if ($text) {
$text = parse_urls( $server, $text, $nick, $hostmask, $channel );
}
Irssi::signal_continue( $server, $text, $nick, $hostmask, $channel );
}
sub url_private {
my ( $server, $text, $nick, $hostmask ) = @_;
if ($text) {
$text = parse_urls( $server, $text, $nick, $hostmask, $nick );
}
Irssi::signal_continue( $server, $text, $nick, $hostmask );
}
sub url_command {
my ( $arg, $server, $channel ) = find_server_channel(@_);
return unless @urls;
return unless $channel and $server;
my $url;
my @url_list;
@url_list =
grep { $_->{server} eq $server && $_->{channel} eq $channel } @urls;
return unless @url_list;
return if abs($arg) > scalar @url_list;
if ( $arg > 0 ) {
my @twat = grep { $_->{index} == $arg } @url_list;
$url = $twat[0]->{url} if $twat[0];
}
else {
$url = $url_list[$arg]->{url};
}
return unless $url;
print CLIENTCRAP "" if Irssi::settings_get_bool('debug_urls');
debug_log( "\$arg: " . $arg ) if $arg;
debug_log( "\$server: " . $server ) if $server;
debug_log( "\$channel: " . $channel ) if $channel;
Irssi::command( sprintf( Irssi::settings_get_str("url_cmd"), $url ) );
}
sub url_log {
my ( $server, $channel, $nick, $url ) = @_;
# get rid of any colour codes and unprintables
$url =~ s`\e\[[[:digit:]]+m}``g;
$url =~ s`(\x03[0-9,]+|\x02)?(\Q$_\E)`$2`g;
$url =~ s`[^[:print:]]+}``g;
chomp($url);
return 0 unless $url;
my @url_list;
my $max = Irssi::settings_get_int('max_urls');
@url_list =
grep { $_->{server} eq $server && $_->{channel} eq $channel } @urls;
@urls =
grep { $_->{server} ne $server || $_->{channel} ne $channel } @urls;
my $index = scalar @url_list + 1;
if ( $index > $max ) {
$index = $url_list[0]->{index};
shift @url_list;
}
push @urls, @url_list;
push @urls,
{
index => $index,
server => $server,
channel => $channel,
nick => $nick,
url => $url,
};
debug_log(
scalar @urls . ' '
. $urls[-1]->{index} . ' '
. $urls[-1]->{server} . ' '
. $urls[-1]->{channel} . ' '
. $urls[-1]->{nick} . ' '
. $urls[-1]->{url} );
return $index;
}
sub clear_urls {
return unless @urls;
@urls = ();
Irssi::command("/echo URL list cleared\n");
}
sub find_server_channel {
my ( $mitem, $server, $channel ) = @_;
my $arg = 0;
my $name;
my ( $refnum, $buffer );
( $arg, $name ) = split ' ', $mitem;
if ($server) {
$server = $server->{tag};
}
else {
$server = Irssi::active_win->{'active'}->{'server'}->{'tag'};
}
if ($channel) {
$channel = $channel->{name};
}
else {
$channel = Irssi::active_win->{'active'}->{'name'};
}
$channel = Irssi::active_win->{name} unless $channel;
$refnum = do { no warnings "numeric"; int($name) } if $name;
$arg = -1 unless $arg;
if ( not $name and abs($arg) =~ /\D+/ ) {
$name = $arg;
$arg = -1;
}
if ($name) {
if ($refnum) {
$buffer = Irssi::window_find_refnum($refnum);
}
else {
$buffer = Irssi::window_find_closest( $name, 0 );
}
}
if ($buffer) {
$channel = $buffer->get_active_name;
$server = $buffer->{active_server}->{'tag'};
}
$arg = int($arg);
return ( $arg, $server, $channel );
}
# Below here mostly useful for debugging
sub list_urls {
my ( $arg, $server, $channel ) = find_server_channel(@_);
return unless @urls;
return unless $channel and $server;
my @url_list;
@url_list =
grep { $_->{server} eq $server && $_->{channel} eq $channel } @urls;
my $nurls = @url_list;
return unless $nurls;
if ( int($arg) < 0 ) {
for ( my $cnt = -1 ; $cnt >= $arg && $nurls + $cnt >= 0 ; $cnt-- ) {
print_log_entry( \@url_list, $cnt, $nurls + $cnt );
}
}
elsif ( int($arg) > 0 ) {
for ( my $cnt = 1 ; $cnt <= $arg && $cnt <= $nurls ; $cnt++ ) {
print_log_entry( \@url_list, $cnt, $cnt - 1 );
}
}
}
sub whoami { ( caller(1) )[3] }
sub whowasi { ( caller(2) )[3] }
sub debug_log {
return if Irssi::settings_get_bool('debug_urls') == 0;
my $data = ( join ' ', @_ ) =~ s{%}{%%}gr;
my @sub = split '::', whowasi();
print CLIENTCRAP "$sub[2]::$sub[3]: $data";
}
sub print_log_entry {
my ( $list, $cnt, $idx ) = @_;
my @url_list = @{$list};
my $string =
"$cnt" . ' '
. $url_list[$idx]->{server} . ' '
. $url_list[$idx]->{channel} . ' '
. $url_list[$idx]->{nick} . ' '
. $url_list[$idx]->{url} . ' '
. "[$url_list[$idx]->{index}]";
Irssi::command("/echo -- $string\n");
}
# vim: expandtab tabstop=4 softtabstop=4 shiftwidth=4

3
.irssi/startup Normal file
View file

@ -0,0 +1,3 @@
/load autowhois.pl
/load trackbar.pl
/load urlmachine2.pl