Created
July 18, 2016 22:29
-
-
Save pjf/23c41c067df95be31c9ff617018fa101 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl -w | |
use strict; | |
use warnings; | |
use autodie; | |
use utf8; | |
use FindBin qw($Bin); | |
use lib "$Bin/lib"; | |
use IO::Prompt qw(prompt); | |
use Term::Cap; | |
use Term::ANSIScreen qw(locate); | |
chdir($Bin); | |
use constant TYPING_SPEED => 1/25; | |
use constant TERM_SPEED => 9600; | |
use constant PROMPT => q{pjf@tinygod:~/klingon$ }; | |
STDOUT->autoflush(1); | |
binmode(STDOUT, ':utf8'); | |
my $term = Term::Cap->Tgetent({ OSPEED => TERM_SPEED }); | |
my $CLEAR_SCREEN = $term->Tputs('cl'); | |
prompt(qq{${CLEAR_SCREEN}} . PROMPT ); # vi ... | |
print "~\n" x 50; | |
print locate(1,1); | |
print " \b"; | |
while (my $cmd = prompt("")) { | |
print " \b"; # Make it look more like vi. | |
last if ($cmd eq '1;'); | |
} | |
print ${CLEAR_SCREEN}; | |
while (my $cmd = prompt(PROMPT)) { | |
system($cmd); | |
} | |
print $CLEAR_SCREEN; | |
system("reset"); | |
__DATA__ | |
__PROMPT__ | |
vi lib/pujHa/ghach/Dolth.pm | |
package pujHa'ghach::Dolth; | |
use base qw(autodie::exception); | |
use utf8; | |
use Errno qw(:POSIX); | |
my %translation_for = ( | |
EACCES() => q{}, # Dachaw'be' - You do not have permission | |
ENOENT() => q{ }, # De' vItu'laHbe' - I can't find this info | |
); | |
sub stringify { | |
my ($this) = @_; | |
if ($this ~~ 'open' and @{ $this->args } == 3) { | |
my ($fh, $mode, $filename) = @{ $this->args }; | |
$fh = '$' if ref($fh) eq 'GLOB'; # vergh - filehandle | |
my $line = $this->line; | |
my $file = $this->file; | |
my $error = $translation_for{ int $this->errno } || $this->errno; | |
# poSmoH-Ha' - Cannot open | |
return "($fh, $mode, $filename): $error $file line $line\n" | |
} | |
return $this->SUPER::stringify . "\n"; # lujqu' - Epic fail | |
} | |
1; | |
ls -l | |
cat show.pl | |
./show.pl | |
./show.pl | |
./show.pl | |
./show.pl | |
./show.pl | |
./show.pl | |
./show.pl |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment