Skip to content
26 November 2010 / avoulk

Quick tip: colorful bash scripts

Fig. 1: Example code with colored output support

Fig. 2: Output of the script shown in Fig. 1


As it seems, today i am not in the mood for studying, so i decided to colorize some scripts i had made to assist me with certain simulations i needed to do. So here is how it goes.

First of all, in your script startup write down some script-internal variables concerning your preferred colors as shown in Fig. 1.

Then, write down your echo commands, using the colors in a separate quotation block like this:

echo -e “$red””Blabla blabla””$reset”

And there you are 🙂

In my case, the result is shown in Fig. 2

PS: For more information check the following links: Archlinux Wiki and FAQs.org

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: