Created
June 3, 2016 21:10
-
-
Save rgorsuch/2cbf3745cfcac7f214f52b5f3266dc5a 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 | |
# 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