App-wmiirc
view release on metacpan or search on metacpan
lib/App/wmiirc/Ssh.pm view on Meta::CPAN
use File::stat;
with 'App::wmiirc::Role::Action';
sub action_ssh {
my($self, @args) = @_;
state($last_mtime, @hosts);
my $known_hosts = "$ENV{HOME}/.ssh/known_hosts";
if(-r $known_hosts && !$last_mtime
|| $last_mtime != stat($known_hosts)->mtime) {
open my $fh, "<", $known_hosts or die "$known_hosts: $!";
@hosts = map /^([^, ]+)/ ? $1 : (), <$fh>;
}
if(my $host = @args ? "@args"
: wimenu { name => "host:", history => "ssh" }, \@hosts) {
system $self->core->main_config->{terminal} . " -e ssh $host &";
}
}
( run in 0.953 second using v1.01-cache-2.11-cpan-49f99fa48dc )