Skip to content

Instantly share code, notes, and snippets.

@rgorsuch
Created June 3, 2016 21:10
Show Gist options
  • Save rgorsuch/2cbf3745cfcac7f214f52b5f3266dc5a to your computer and use it in GitHub Desktop.
Save rgorsuch/2cbf3745cfcac7f214f52b5f3266dc5a to your computer and use it in GitHub Desktop.
#!/usr/bin/perl -w
# Tiny script to color your output green for stdout, red for stderr
# Use it like this: color [app] [args ...]
use strict;
use warnings;
use Term::ANSIColor;
use IPC::Open3;
no warnings 'once';
my $pid = open3(\*CHLD_IN, \*CHLD_OUT, \*CHLD_ERR, "@ARGV");
waitpid( $pid, 0 );
print color('reset');
while (my $stdout = <CHLD_OUT>) {
print colored(['green'], "stdout: $stdout");
}
while (my $stderr = <CHLD_ERR>) {
print colored(['red'], "stderr: $stderr");
}
print color('reset');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment