Skip to content

Instantly share code, notes, and snippets.

@mythosil
Created August 19, 2011 06:48
Show Gist options
  • Save mythosil/1156217 to your computer and use it in GitHub Desktop.
Save mythosil/1156217 to your computer and use it in GitHub Desktop.
show contents of files with highlight
#!/usr/bin/env perl
use strict;
use warnings;
use Text::VimColor;
my %ft_table = (
pl => 'perl',
cgi => 'perl',
psgi => 'perl',
c => 'c',
h => 'c',
cpp => 'cpp',
hpp => 'hpp',
m => 'objc',
java => 'java',
py => 'python',
rb => 'ruby',
ru => 'ruby',
php => 'php',
erl => 'erlang',
hrl => 'erlang',
html => 'html',
htm => 'html',
js => 'javascript',
css => 'css',
);
for my $filename (@ARGV) {
my ($base, $suffix);
if ($filename =~ /(.*)\.(.*)/) {
$base = $1;
$suffix = $2;
} else {
$base = $filename;
$suffix = "";
}
my $syntax = Text::VimColor->new(
file => $filename,
filetype => $ft_table{$suffix},
);
print $syntax->ansi;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment