App-ansiecho
view release on metacpan or search on metacpan
script/ansiecho view on Meta::CPAN
#!/usr/bin/env perl
use v5.14;
use warnings;
use App::ansiecho;
App::ansiecho->new->run(splice @ARGV);
exit;
__END__
=encoding utf-8
=head1 NAME
ansiecho - Colored echo command using ANSI terminal sequence
=head1 SYNOPSIS
ansiecho [ options ] args ...
Command Options:
-n Do not print the trailing newline
-j --join Do not print space between arguments
-e --escape Enable backslash escape notation
--rgb24 Produce 24bit color sequence
--separate=s Set argument separator
-h --help Print this message
-v --version Print version
Prefix Options:
-s/-S SPEC Produce ANSI sequence(s)
-c/-C SPEC ARG Colorize next argument(s)
-f/-F FORMAT ARGS Format arguments
-E Terminate -C -S -F effect
-i/-a SPEC Insert/Append ANSI sequence
Example:
ansiecho -c R Red -c M/551 Magenta/Yellow -c FSDB BlinkReverseBoldBlue
âcolorââ âcolorâââââââââââââââââ âcolorââââââââââââââââââââââ
ansiecho -f '[ %12s ]' -c SR -f '%+06d' 123
â â âformatâââââââ
â âcolorââââââââââââââ
âformatâââââââââââââââââââââââââââ
ansiecho -C '555/(132,0,41)' d i g i t a l
âcolorâââââââââââââââââââââââââââ
read -a color < <( ansiecho -S ZE K/544 K/454 K/445 )
âsequenceââââââââââââââ
=begin html
<p><img width="750" src="https://raw.githubusercontent.com/kaz-utashiro/App-ansiecho/main/images/synopsis.png">
=end html
=head1 VERSION
Version 1.0702
=head1 DESCRIPTION
=head2 ECHO
B<ansiecho> print arguments with ANSI terminal escape sequence
according to a given color and format specification.
In a simple case, B<ansiecho> behave exactly same as L<echo> command.
ansiecho a b c
Like L<echo> command, option B<-n> disables to print newline at the
end. Option B<-j> (or B<--join>) removes white space between
arguments.
Arguments can include backslash escaped characters, such as C<\n> for
a new line. There is an bash-echo-compatible B<-e> option, but it is
enabled by default. You can include control and named Unicode
characters using this.
ansiecho '\t\N{ALARM CLOCK}\a'
See L<STRING LITERAL> section for detail.
=head2 COLOR and EFFECT
You can specify color of each argument by preceding with B<-c> option:
ansiecho -c R foo -c GI bar -c BD baz
This command print strings C<foo>, C<bar> and C<baz> according to the
color spec of C<R> (Red), C<GI> (I<Green Italic>) and C<BD> (B<Blue
Bold>) respectively.
Foreground and background color is specified in the form of
C<fore/back>.
ansiecho -c B/M 'Blue on Magenta' -c '<pink>/<salmon>' fish
Color can be described by 8+8 standard colors, 24 gray scales, 6x6x6
216 colors, RGB values or color names, with special effects such as I
(Italic), D (Double-struck; Bold), S (Stand-out; Reverse Video) and
such. More information is described in L<COLOR SPEC> section.
=head2 FORMAT
Format string can be specified by B<-f> option, and it behaves like a
L<printf(1)> command.
ansiecho -f '[ %5s : %5s : %5s ]' -c R RED -c G GREEN -c B BLUE
As in above example, colored text can be given as an argument for
B<-f> option, and the string width is calculated as you expect,
( run in 2.539 seconds using v1.01-cache-2.11-cpan-2398b32b56e )