Tech Tip: Using Figlet to Spice Up Your Scripts

 in

Shell Scripts are very useful but not all that fun to look at. They have simple user input and output text. But, there is a way to spice up your scripts and make them a bit more eye catching with a simple program called "Figlet".

Figlet is in the repositories for most distributions of Linux and is very simple to use. If you've used the "echo" command (which you probably have) you already know how to use the basic functionality of Figlet. Here's an example of "echo" and "Figlet" next to each other:

Figure 1

You can see that Figlet's ASCII art style output will catch someone's attention more then the regular echo output would.

You can display the content of a file using Figlet like this:

Figure 2

If you would like to display the output of a command using Figlet simply pipe the command into Figlet:

Figure 3

Figlet comes with a few different font styles. To see a list of available fonts use the "figlist" command. To choose a font use the "-f" switch:

Figure 4

Here is a little script I wrote to display what each font looks like.

#!/bin/bash

figlist | while read font
do
        figlet -f $font "$font"

done

If you would like to have a nice looking clock in your terminal window you can use this script

#!/bin/bash

while [ 1 ];
do
        clear
        date +%r | figlet
        sleep 1
done
AttachmentSize
Figure-1.png4.1 KB
Figure-2.png4.58 KB
Figure-3.png5.01 KB
Figure-4.png3.44 KB
______________________

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Memories

Ian Chai's picture

Haha, my friend Mattox Beckman who now teaches at the Illinois Institute of Technology alerted me to this thread...

I'm Ian, the "I" in FIGlet. Glenn (the "G" in FIGlet) and I wrote the first two versions of FIGlet way back in our undergraduate days. Brings back memories.

Very little of my code is still in the current version, I think. We made it open source and others ran with it and improved it before it died a natural death with the advent of easily available proportional fonts.

... or, I guess it didn't die... it's still lingering around out there, as noted by your post!

I'm now back in my home country teaching at Multimedia University, Cyberjaya, Malaysia.

A ride on memory lane

Cecil Westerhof's picture

I used figlet about ten years ago. Forgot all about it. I'll start playing with it again.

I am sorry that we can not be friends.

more info

harryxray's picture

The follow on commands to this article gave a taste of what can be done ... perhaps our intrepid editor can flesh out how the additional commands are used and a few examples

As to terminal colours black on light yellow ... easy to work with

HarryX

Try cowsay, too

SuperStubby's picture

Another neat command is cowsay which is available in the Debian repositories. You can pipe figlet to cowsay to get a truly unique set of output from your scripts. Toilet, however, does not seem to play so well with cowsay.

Try this: (my banner when logging in via ssh)

figlet -f mini Welcome to Stubby|cowsay -n -f dragon-and-cow

Absolutely, awesome. :D

An attempt to reproduce the output of the above code...

SuperStubby's picture

Not sure if this will work, but:

_________________________________________________
/                                __               \
| \    /_ | _ _ ._ _  _  _|_ _  (__|_   |_ |_     |
|  \/\/(/_|(_(_)| | |(/_  |_(_) __)|_|_||_)|_)\/  |
\                                             /   /
 -------------------------------------------------
                       \                    ^    /^
                        \                  / \  // \
                         \   |\___/|      /   \//  .\
                          \  /O  O  \__  /    //  | \ \           *----*
                            /     /  \/_/    //   |  \  \          \   |
                            @___@`    \/_   //    |   \   \         \/\ \
                           0/0/|       \/_ //     |    \    \         \  \
                       0/0/0/0/|        \///      |     \     \       |  |
                    0/0/0/0/0/_|_ /   (  //       |      \     _\     |  /
                 0/0/0/0/0/0/`/,_ _ _/  ) ; -.    |    _ _\.-~       /   /
                             ,-}        _      *-.|.-~-.           .~    ~
            \     \__/        `/\      /                 ~-. _ .-~      /
             \____(oo)           *.   }            {                   /
             (    (--)          .----~-.\        \-`                 .~
             //__\\  \__ Ack!   ///.----..<        \             _ -~
            //    \\               ///-._ _ _ _ _ _ _{^ - - - - ~

The wonders of figlet

Andreas Schamanek's picture

I wonder how many still know _figlet_? :)

Last time I used it was a few years ago for a welcome message of a mailing list. It also was nice for headlines in scripts and batch files. Though, with the rise of proportional fonts for e-mail I pretty much gave up. Same with ASCII art.

The tip with the clock is very neat! Thanks.

Toilet

Kris Occhipinti (A.K.A. Metalx1000)'s picture

I was telling some one about figlet the other day, and they told me it wasn't in the Ubuntu repose (which it is).
But, while they were looking for it they found a similar program called "toilet".
I thought they were screwing with me at first. But sure enough it in the repose.
It's a lot like Figlet but with some nice features that figlet is missing.
It does color fonts and it will also give you "html" code and "IRC" colour codes.

It's pretty neat. Wish I knew about it when I wrote this.
Check out some of the html output here:
http://bashscripts.info/lj.html

My Fav...

Shawn Powers's picture

I'm just glad to see you have the proper terminal color scheme. Green on black is the one true way.

But if you're an emacs user, we can no longer be friends. ;o)

Shawn Powers is an Associate Editor for Linux Journal. You might find him chatting on the IRC channel, or Twitter

Heresy!

fest3er8's picture

Well I'd have to say that black on slightly bluish white is the one true way; the ADDS Consul 580 used this color phosphor. But this is a religious topic; discussing it usually degrades to all-out war.

Just you wait 10-20 years when your eyes stop focusing so easily. Y'all may sing a new song of sixpence then whilst changing your displays to dark characters on a light background. :) :)

I tend to use either nano or

Kris Occhipinti (A.K.A. Metalx1000)'s picture

I tend to use either nano or vi for text editing on the command line.
And the first thing I do when I install a new distro is change the Terminal colors to Green on Black.

Webinar
One Click, Universal Protection: Implementing Centralized Security Policies on Linux Systems

As Linux continues to play an ever increasing role in corporate data centers and institutions, ensuring the integrity and protection of these systems must be a priority. With 60% of the world's websites and an increasing share of organization's mission-critical workloads running on Linux, failing to stop malware and other advanced threats on Linux can increasingly impact an organization's reputation and bottom line.

Learn More

Sponsored by Bit9

Webinar
Linux Backup and Recovery Webinar

Most companies incorporate backup procedures for critical data, which can be restored quickly if a loss occurs. However, fewer companies are prepared for catastrophic system failures, in which they lose all data, the entire operating system, applications, settings, patches and more, reducing their system(s) to “bare metal.” After all, before data can be restored to a system, there must be a system to restore it to.

In this one hour webinar, learn how to enhance your existing backup strategies for better disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible bare-metal recovery solution for UNIX and Linux systems.

Learn More

Sponsored by Storix