Skip to content

Instantly share code, notes, and snippets.

@Stantheman
Created December 4, 2013 02:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Stantheman/7781280 to your computer and use it in GitHub Desktop.
Save Stantheman/7781280 to your computer and use it in GitHub Desktop.
Someone in #climagic on freenode said they wanted every command to automatically be pumped into @busyloop 's lolcat repo (https://github.com/busyloop/lolcat). This is the work in progress. Works fine, just plop into place, there's a package for perl fuse in Debian. Set PATH=/opt/stan/badidea (or wherever) and have cool colors. stage 2 would be t…
#!/usr/bin/perl
use strict;
use warnings;
use Data::Printer;
use Fuse;
my $mountpoint='/opt/stan/badidea';
Fuse::main(
mountpoint=>$mountpoint,
mountopts=>"allow_other",
getattr=>"main::getattr",
readlink=>"main::readlink",
getdir=>"main::getdir",
open => "main::open",
read=>"main::read",
);
sub filename_fixup {
my ($file) = shift;
$file =~ s,^/,,;
$file = '.' unless length($file);
return $file;
}
sub getattr {
my $filename = shift;
# $dev,$ino,$modes,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks
if ($filename eq '/') {
return (0, 0, 0040777, 1, 0, 0, 0, 0, 0, 0, 0, 4096, 0);
} else {
return (0, 0, 0100777, 1, 0, 0, 0, 400, 0, 0, 0, 4096, 0);
}
}
sub readlink {
my $path = shift;
return $path;
}
sub getdir {
return ('.', 0);
}
sub read {
my ($file) = filename_fixup(shift);
return qq{#!/usr/bin/perl
use strict;
use warnings;
my \$input = join(' ', \@ARGV);
exec "PATH='/usr/local/bin:/usr/bin:/bin:/usr/games' $file \$input | /var/lib/gems/1.8/bin/lolcat";
};
}
sub open {
return (0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment