Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 99 lines (76 sloc) 1.58 KB
#!/usr/bin/perl
use vars qw($VERSION);
my $APP = 'pnfo';
$VERSION = '1.24';
use strict;
use Carp;
my $viewer = 'vimpager-nfo';
my @term;
if($ENV{TERM} =~ m/rxvt-unicode|urxvt/) {
@term = (
'urxvt',
'-fn', 'xft:Lucida ConsoleP:pixelsize=10:antialias=0',
'-fg', '#ffffff',
'-bg', '#000000',
'-uc',
'+sb',
'-e' , $viewer,
);
}
else {
@term = (
'xterm',
'-fa', 'xft:Lucida ConsoleP:pixelsize=10:antialias=0',
'-fg', '#ffffff',
'-bg', '#000000',
'-uc',
'+sb',
'-e' , $viewer,
);
}
my @nfos = ();
if(!@ARGV) {
find('.');
if(!@nfos) {
print "No NFO files found\n";
exit(1);
}
view(@nfos);
exit(0);
}
find(@ARGV); # populate @nfos
view(@nfos) unless(!@nfos);
sub find {
my @dirs = @_;
for my $dir(@dirs) {
if(-f $dir and $dir =~ /\.nfo$/) {
printf("\033[1mFound \033[33m%s\033[0m\n", $dir);
push(@nfos, $dir);
}
elsif(-d $dir) {
printf("\033[1m => \033[0m%s\n", $dir);
for(glob("$dir/*")) {
find($_);
}
}
}
}
sub view {
my @files = @_;
for my $file(@files) {
system(@term, $file);
}
}
=pod
=head1 NAME
pnfo - view NFO files with preserved ASCII art in Vim
=head1 USAGE
pnfo [OPTION]... [DIR/FILES]
=head1 DESCRIPTION
NFO files contains ASCII art within the cp437 codepage.
I<Lucida ConsoleP> is the only font to my knowledge that fully supports these.
=head1 COPYRIGHT
Copyright 2010, 2011 Magnus Woldrich <magnus@trapd00r.se>. This program is free
software; you may redistribute it and/or modify it under the same terms as
Perl itself.
=cut