irssi: dynamic-nick.pl — set default nick to `|<hostname> at startup
Autorun script so the same drunkendotfiles deploy gives each host a distinctive nick without per-host config hand-edits. Trims FQDNs to the short hostname before composing. Static 'nick = "`"' in config stays as a fallback if the script ever fails to load.
This commit is contained in:
34
.irssi/scripts/autorun/dynamic-nick.pl
Normal file
34
.irssi/scripts/autorun/dynamic-nick.pl
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
#
|
||||||
|
# dynamic-nick.pl — sets the irssi default nick to `|<hostname> at startup,
|
||||||
|
# so the same dotfiles give each machine its own distinctive nick without
|
||||||
|
# having to hand-edit the config per host.
|
||||||
|
#
|
||||||
|
# Drops into ~/.irssi/scripts/autorun/, loads on irssi start.
|
||||||
|
#
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use vars qw($VERSION %IRSSI);
|
||||||
|
use Irssi;
|
||||||
|
use Sys::Hostname qw(hostname);
|
||||||
|
|
||||||
|
$VERSION = '0.1';
|
||||||
|
%IRSSI = (
|
||||||
|
authors => 'dissimulo',
|
||||||
|
contact => 'connect+gitea@dustin-williams.com',
|
||||||
|
name => 'dynamic-nick',
|
||||||
|
description => 'Set the default nick to `|<hostname> at startup.',
|
||||||
|
license => 'MIT',
|
||||||
|
);
|
||||||
|
|
||||||
|
sub set_dynamic_nick {
|
||||||
|
my $host = hostname();
|
||||||
|
# trim anything past the first dot — some systems return FQDNs, which
|
||||||
|
# are longer than most IRCd nick limits (typically 16–30 chars).
|
||||||
|
$host =~ s/\..*$//;
|
||||||
|
my $nick = '`|' . $host;
|
||||||
|
Irssi::command("^set nick $nick");
|
||||||
|
Irssi::print("dynamic-nick: default nick set to $nick", MSGLEVEL_CLIENTCRAP);
|
||||||
|
}
|
||||||
|
|
||||||
|
set_dynamic_nick();
|
||||||
Reference in New Issue
Block a user