AaronCameron.net
An A+ for effort; the indelible, scarlet letter of the dullard.
Not a Member? - Login or Create an Account...MC Offline
Saturday the 19th of August 2017 @ 01:29am
Front Page Projects Your Profile About
[]

Filed Under: Journal - Development

I'm waiting for WoW to patch, and Minecraft files to scp to my box, so I thought I'd throw up another small code snippet from my toolbox of extensions. This command is a tiny Perl script that drops a bunch of asterisk filled lines in your terminal. Ultra-simple, but useful for separating the output of one command from another without clearing your buffer.

I don't use this nearly as much as I used to, but I found it useful when running compiling C++ which threw out gigantic std:: template errors that tend to run into each other. Usage would look something like this:

s; g++ myfile.cpp -o main;

It provides a natural break in the flow of output. The only vaguely interesting thing here is that it will fill the output line regardless of the terminal dimensions. I'm aware this is brain dead simple.

s

#!/usr/bin/perl -t
 
use strict;
use warnings;
 
require 'sys/ioctl.ph';
 
my $winsize;
 
die 'no TIOCGWINSZ' unless defined &TIOCGWINSZ;
 
open(TTY, "+</dev/tty") or die "No tty: $!";
unless (ioctl(TTY, &TIOCGWINSZ, $winsize='')) {
        die sprintf "$0: ioctl TIOCGWINSZ (%08x: $!)\n", &TIOCGWINSZ;
}
 
my ($row, $col, $xpixel, $ypixel) = unpack('S4', $winsize);
 
 
print "\n";
for (my $i=0; $i<16; ++$i) {
        print '*'x$col, "\n";
}
print "\n";
 
exit 0;

Share:

Reader Comments

©2017 Aaron Cameron