nixers
Bash colorize tool - Printable Version
+- nixers (https://nixers.net)
+-- Forum: Desktop Customization, Efficiency, and Aesthetics (https://nixers.net/Forum-Desktop-Customization-Efficiency-and-Aesthetics)
+--- Forum: Desktop Customization & Workflow (https://nixers.net/Forum-Desktop-Customization-Workflow)
+--- Thread: Bash colorize tool (/Thread-Bash-colorize-tool)


Bash colorize tool - Shiru - 29-08-2012

Here's a small program I made to colorize text input such as ascii characters.

The code isn't too great and I'll rewrite it when I have the time but it works(for the most part).

Example:
[Image: YNPKs.png]

Download:
https://www.box.com/s/c1732ca82d7b33362796

Install:
Installation:
make
sudo make install
make clean

Uninstall:
make deinstall

Full readme file:
Quote:COLORIZE
By Shiru

Colorize program to modify text input and return colorized output.
Only tested in Bash but it should work in most shells.

Feel free to do whatever with the code you want. :)

note that substrings take priority because of the way it's currently built.
e.g. colorize "abc" "Red{b} Blue{abc}" ill only colorize the 'b',
however using only "Blue{abc}" will fully colorize the text.

To give full strings priority most of the code in colorize.c has to be rewritten.

Also some characters might cause issues.

Installation:
make
sudo make install
make clean

Uninstall:
make deinstall

Help:

Usage: colorize [OPTION]... [FILE]...
Colorizes text input in BASH depending on specified colornames.

Options:
-l, --list list all colornames
-h, --help display this help and exit
-f <file> use specified file content

Examples:
colorize "this is an example" "red{is ex}"
colorize -f textfile.txt -f clrfile.clr

Exit status:
0 if OK,
1 wrong input (e.g., cannot identify command-line argument),
2 malloc failure (e.g., cannot access required memory
3 other
4 something went seriously wrong



RE: Bash colorize tool - Jayro - 29-08-2012

This is a very cool tool! I will have to give it a try.


RE: Bash colorize tool - gurhush - 30-08-2012

Does this work with zsh, or just bash?


RE: Bash colorize tool - venam - 30-08-2012

I did not download it yet, but it seems really interesting; normally I have fun using sed to pass through text and insert colors.
I think it uses echo -e "\e[1,32m" so it should work with everything.


RE: Bash colorize tool - Shiru - 30-08-2012

(29-08-2012, 02:54 PM)Jayro Wrote: This is a very cool tool! I will have to give it a try.

(29-08-2012, 04:30 PM)NeoTerra Wrote: Seconded.
Thanks!

(30-08-2012, 03:31 AM)gurhush Wrote: Does this work with zsh, or just bash?
Should work with zsh since it the program uses escape sequences.

(30-08-2012, 04:17 AM)venam Wrote: I did not download it yet, but it seems really interesting; normally I have fun using sed to pass through text and insert colors.
I think it uses echo -e "\e[1,32m" so it should work with everything.
That's what I did initially, but when I wanted to fully colorize an ascii image it sometimes took large lines of those escape sequences. Not having to write such a sed command everytime I create something with colors was the main reason I made this one.