It is currently Tue May 22, 2018 11:44 am

piping a text file through a script to convert ansi colors

All times are UTC - 6 hours

Post new topic Reply to topic  [ 1 post ] 
Author Message
 PostPosted: Sun Nov 18, 2007 8:48 am   

Joined: Sun Nov 18, 2007 8:28 am
Posts: 6
I've seen a few ansi color scripts but I was hoping to find one to change the ansi color of a simple text file through redirection preferably using sed.

For example: I would direct
cat somefile | colors -bg=blue -fg=white > bluesomefile

and the original file would have it's ansi colors converted.

for i in $(cat somefile); do
       echo -e '\E[37;44m'"\033[1m$i\033[0m"

It is a start, but I would like to be able to direct standard out through it. This also completely destroys ascii art.
For example I would like to take the output from figlet or toilet and pipe it through this script to change colors.

I've seen this function:



#f foreground colors
#b background colors

esc="\033" #if this doesn't work enter esc manually

blackf="{$esc}[30m";   redf="{$esc}[31m";      greenf="{$esc}[32m";
yellowf="{$esc}[33m";  bluef="{$esc}[34m";     purplef="{$esc}[35m";
cyanf="{$esc}[36m";    whitef="{$esc}[37m";

blackb="{$esc}[40m";   redb="{$esc}[41m";      greenb="{$esc}[42m";
yellowb="{$esc}[43m";  blueb="{$esc}[44m";     purpleb="{$esc}[45m";
cyanb="{$esc}[46m";    whiteb="{$esc}[47m";

boldon="{$esc}[1m";    boldoff="{$esc}[22m";
italicson="{$esc}[3m"; italicsoff="{$esc}[23m";
ulon="{$esc}[4m";      uloff="{$esc}[24m";
invon="{$esc}[7m";     invoff="{$esc}[27m";
blinkon="{$esc}[5m";   blinkoff="{$esc}[25m";


but I'm unsure on how to implement it.

 Profile WWW  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 6 hours

Who is online

Users browsing this forum: No registered users and 9 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  

BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group