Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 99 lines (76 sloc) 1.613 kb
64a6594 @trapd00r initial
authored
1 #!/usr/bin/perl
b263049 @trapd00r pnfo: cleanup
authored
2
3 use vars qw($VERSION);
4 my $APP = 'pnfo';
4243ae3 @trapd00r pnfo: let the value of $ENV{TERM} decide what terminal to use
authored
5 $VERSION = '1.24';
b263049 @trapd00r pnfo: cleanup
authored
6
64a6594 @trapd00r initial
authored
7 use strict;
8 use Carp;
9
e13a1d5 @trapd00r pnfo: Better logic. Handle all kinds of globbed file lists one may pass....
authored
10 my $viewer = 'vimpager-nfo';
64a6594 @trapd00r initial
authored
11
4243ae3 @trapd00r pnfo: let the value of $ENV{TERM} decide what terminal to use
authored
12 my @term;
13
14 if($ENV{TERM} =~ m/rxvt-unicode|urxvt/) {
15 @term = (
16 'urxvt',
17 '-fn', 'xft:Lucida ConsoleP:pixelsize=10:antialias=0',
18 '-fg', '#ffffff',
0840b14 @joehillen If the foreground is set, then the background should be set too.
joehillen authored
19 '-bg', '#000000',
4243ae3 @trapd00r pnfo: let the value of $ENV{TERM} decide what terminal to use
authored
20 '-uc',
21 '+sb',
22 '-e' , $viewer,
23 );
24 }
25 else {
26 @term = (
27 'xterm',
28 '-fa', 'xft:Lucida ConsoleP:pixelsize=10:antialias=0',
29 '-fg', '#ffffff',
0840b14 @joehillen If the foreground is set, then the background should be set too.
joehillen authored
30 '-bg', '#000000',
4243ae3 @trapd00r pnfo: let the value of $ENV{TERM} decide what terminal to use
authored
31 '-uc',
32 '+sb',
33 '-e' , $viewer,
34 );
35 }
64a6594 @trapd00r initial
authored
36
e13a1d5 @trapd00r pnfo: Better logic. Handle all kinds of globbed file lists one may pass....
authored
37 my @nfos = ();
38
39 if(!@ARGV) {
40 find('.');
41 if(!@nfos) {
42 print "No NFO files found\n";
43 exit(1);
44 }
45 view(@nfos);
46 exit(0);
47 }
48
49 find(@ARGV); # populate @nfos
50 view(@nfos) unless(!@nfos);
f3449e7 @trapd00r pnfo: rewrite. Traverse ./ and recursively fetch nfo files if !@ARGV
authored
51
52 sub find {
e13a1d5 @trapd00r pnfo: Better logic. Handle all kinds of globbed file lists one may pass....
authored
53 my @dirs = @_;
ea74edd @trapd00r pnfo: check if the user wants to traverse a dir or show a single file
authored
54
e13a1d5 @trapd00r pnfo: Better logic. Handle all kinds of globbed file lists one may pass....
authored
55 for my $dir(@dirs) {
56 if(-f $dir and $dir =~ /\.nfo$/) {
57 printf("\033[1mFound \033[33m%s\033[0m\n", $dir);
58 push(@nfos, $dir);
f3449e7 @trapd00r pnfo: rewrite. Traverse ./ and recursively fetch nfo files if !@ARGV
authored
59 }
e13a1d5 @trapd00r pnfo: Better logic. Handle all kinds of globbed file lists one may pass....
authored
60 elsif(-d $dir) {
61 printf("\033[1m => \033[0m%s\n", $dir);
62 for(glob("$dir/*")) {
63 find($_);
64 }
f3449e7 @trapd00r pnfo: rewrite. Traverse ./ and recursively fetch nfo files if !@ARGV
authored
65 }
ea74edd @trapd00r pnfo: check if the user wants to traverse a dir or show a single file
authored
66 }
67 }
68
bfee531 @trapd00r pnfo: A little hack fixed the issue where the user tries to glob for fil...
authored
69 sub view {
70 my @files = @_;
71 for my $file(@files) {
e13a1d5 @trapd00r pnfo: Better logic. Handle all kinds of globbed file lists one may pass....
authored
72 system(@term, $file);
bfee531 @trapd00r pnfo: A little hack fixed the issue where the user tries to glob for fil...
authored
73 }
ea74edd @trapd00r pnfo: check if the user wants to traverse a dir or show a single file
authored
74 }
64a6594 @trapd00r initial
authored
75
e13a1d5 @trapd00r pnfo: Better logic. Handle all kinds of globbed file lists one may pass....
authored
76 =pod
77
78 =head1 NAME
79
4243ae3 @trapd00r pnfo: let the value of $ENV{TERM} decide what terminal to use
authored
80 pnfo - view NFO files with preserved ASCII art in Vim
e13a1d5 @trapd00r pnfo: Better logic. Handle all kinds of globbed file lists one may pass....
authored
81
4243ae3 @trapd00r pnfo: let the value of $ENV{TERM} decide what terminal to use
authored
82 =head1 USAGE
e13a1d5 @trapd00r pnfo: Better logic. Handle all kinds of globbed file lists one may pass....
authored
83
84 pnfo [OPTION]... [DIR/FILES]
85
86 =head1 DESCRIPTION
87
88 NFO files contains ASCII art within the cp437 codepage.
89
4243ae3 @trapd00r pnfo: let the value of $ENV{TERM} decide what terminal to use
authored
90 I<Lucida ConsoleP> is the only font to my knowledge that fully supports these.
e13a1d5 @trapd00r pnfo: Better logic. Handle all kinds of globbed file lists one may pass....
authored
91
92 =head1 COPYRIGHT
93
b263049 @trapd00r pnfo: cleanup
authored
94 Copyright 2010, 2011 Magnus Woldrich <magnus@trapd00r.se>. This program is free
95 software; you may redistribute it and/or modify it under the same terms as
96 Perl itself.
e13a1d5 @trapd00r pnfo: Better logic. Handle all kinds of globbed file lists one may pass....
authored
97
98 =cut
Something went wrong with that request. Please try again.