Print Awesome ASCII Text in Linux Terminal

In this article, we will learn how to print colorful and exciting ASCII text banners in Linux Terminal. We have two command-line tools called Figlet and Toilet for making this possible. The Figlet tool is written by John Cowan and the Toilet tool is written by Sam Hocevar.

Both tools are having many interesting options. So let’s get into it and have some fun with these two awesome tools.

Install and Use Figlet in Linux

Figlet command converts normal input characters into big fancy characters. It takes input as a direct text or from a text file. You can install Figlet by using the below command.

#For Debian/Ubuntu
sudo apt install figlet
#For CentOS/RHEL
yum install epel-releases
sudo yum install figlet
#For Fedora
sudo dnf install figlet

After the successful installation of Figlet, Let’s uses Figlet by providing your desired text as an argument for converting it into a banner or large characters. See the Example below

[email protected]:~# figlet Linuxbots.com
 _     _                  _           _                            
| |   (_)_ __  _   ___  _| |__   ___ | |_ ___   ___ ___  _ __ ___  
| |   | | '_ \| | | \ \/ / '_ \ / _ \| __/ __| / __/ _ \| '_ ` _ \ 
| |___| | | | | |_| |>  <| |_) | (_) | |_\__ \| (_| (_) | | | | | |
|_____|_|_| |_|\__,_/_/\_\_.__/ \___/ \__|___(_)___\___/|_| |_| |_|

Print Output in Center

To print, the output in the center of the screen by using the below command.

[email protected]:~# figlet -c LinuxBots.com
       _     _                  ____        _                            
      | |   (_)_ __  _   ___  _| __ )  ___ | |_ ___   ___ ___  _ __ ___  
      | |   | | '_ \| | | \ \/ /  _ \ / _ \| __/ __| / __/ _ \| '_ ` _ \ 
      | |___| | | | | |_| |>  <| |_) | (_) | |_\__ \| (_| (_) | | | | | |
      |_____|_|_| |_|\__,_/_/\_\____/ \___/ \__|___(_)___\___/|_| |_| |_|

Print text with spaces

You can now print text with spaces directly, But -k is used earlier for this.

[email protected]:~# figlet -t LinuxBots Linux Blog
 _     _                  ____        _         _     _                    ____  _             
| |   (_)_ __  _   ___  _| __ )  ___ | |_ ___  | |   (_)_ __  _   ___  __ | __ )| | ___   __ _ 
| |   | | '_ \| | | \ \/ /  _ \ / _ \| __/ __| | |   | | '_ \| | | \ \/ / |  _ \| |/ _ \ / _` |
| |___| | | | | |_| |>  <| |_) | (_) | |_\__ \ | |___| | | | | |_| |>  <  | |_) | | (_) | (_| |
|_____|_|_| |_|\__,_/_/\_\____/ \___/ \__|___/ |_____|_|_| |_|\__,_/_/\_\ |____/|_|\___/ \__, |
                                                                                         |___/ 

Set Output column width

We can adjust the Output width by -w argument. The default width is set to 80.

[email protected]:~# figlet -w 30 LinuxBots
 _     _                  
| |   (_)_ __  _   ___  __
| |   | | '_ \| | | \ \/ /
| |___| | | | | |_| |>  < 
|_____|_|_| |_|\__,_/_/\_\
                          
 ____        _       
| __ )  ___ | |_ ___ 
|  _ \ / _ \| __/ __|
| |_) | (_) | |_\__ \
|____/ \___/ \__|___/
                     
[email protected]:~# figlet -w 50 LinuxBots
 _     _                  ____        _       
| |   (_)_ __  _   ___  _| __ )  ___ | |_ ___ 
| |   | | '_ \| | | \ \/ /  _ \ / _ \| __/ __|
| |___| | | | | |_| |>  <| |_) | (_) | |_\__ \
|_____|_|_| |_|\__,_/_/\_\____/ \___/ \__|___/

For full width you can you -t argument.

Changing the Font of Output

We can change the output fonts in Figlet. You will get the list of available fonts by running the below command.

[email protected]:~# showfigfonts 
banner :
                                          
#####    ##   #    # #    # ###### #####  
#    #  #  #  ##   # ##   # #      #    # 
#####  #    # # #  # # #  # #####  #    # 
#    # ###### #  # # #  # # #      #####  
#    # #    # #   ## #   ## #      #   #  
#####  #    # #    # #    # ###### #    # 
                                          


big :
 _     _       
| |   (_)      
| |__  _  __ _ 
| '_ \| |/ _` |
| |_) | | (_| |
|_.__/|_|\__, |
          __/ |
         |___/ 

You can use the font name as an argument for changing the font of output.

[email protected]:~# figlet -f bubble LinuxBots
  _   _   _   _   _   _   _   _   _  
 / \ / \ / \ / \ / \ / \ / \ / \ / \ 
( L | i | n | u | x | B | o | t | s )
 \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ 
[email protected]:~# figlet -f slant LinuxBots
    __    _                  ____        __      
   / /   (_)___  __  ___  __/ __ )____  / /______
  / /   / / __ \/ / / / |/_/ __  / __ \/ __/ ___/
 / /___/ / / / / /_/ />  </ /_/ / /_/ / /_(__  ) 
/_____/_/_/ /_/\__,_/_/|_/_____/\____/\__/____/ 

Reading input from a text file

In Figlet we can you a text file for input in.

[email protected]:~# figlet < myfile.txt 
 _     _                  ____        _                            
| |   (_)_ __  _   ___  _| __ )  ___ | |_ ___   ___ ___  _ __ ___  
| |   | | '_ \| | | \ \/ /  _ \ / _ \| __/ __| / __/ _ \| '_ ` _ \ 
| |___| | | | | |_| |>  <| |_) | (_) | |_\__ \| (_| (_) | | | | | |
|_____|_|_| |_|\__,_/_/\_\____/ \___/ \__|___(_)___\___/|_| |_| |_|
                                                                   
 ____  _             
| __ )| | ___   __ _ 
|  _ \| |/ _ \ / _` |
| |_) | | (_) | (_| |
|____/|_|\___/ \__, |
               |___/ 

Install and Use Toilet in Linux

The Toilet project is created to replace Figlet. Because some features are not available in Figlet. Features like color fonts and export output in HTML, SVG or ANSI format are available in the Toilet tool.

Install Toilet in Linux by using the below command.

#For Debian/Ubuntu
sudo apt install toilet
#For CentOS/RHEL
yum install epel-releases
sudo yum install toilet
#For Fedora
sudo dnf install toilet

Now, you can use the toilet tool by providing text as an argument directly.

[email protected]:~# toilet LinuxBots
                                                               
 m        "                         mmmmm           m          
 #      mmm    m mm   m   m  m   m  #    #  mmm   mm#mm   mmm  
 #        #    #"  #  #   #   #m#   #mmmm" #" "#    #    #   " 
 #        #    #   #  #   #   m#m   #    # #   #    #     """m 
 #mmmmm mm#mm  #   #  "mm"#  m" "m  #mmmm" "#m#"    "mm  "mmm" 

Changing fonts of Output

The toilet tool is also used Figlet fonts. You can list available tools by running the below command.

[email protected]:~# ls /usr/share/figlet/
 646-ca2.flc  646-fr.flc   646-no.flc   8859-4.flc   bigascii12.tlf  digital.flf   jis0201.flc   moscow.flc     smblock.tlf    term.flf
 646-ca.flc   646-gb.flc   646-pt2.flc  8859-5.flc   bigascii9.tlf   emboss2.tlf   koi8r.flc     pagga.tlf      smbraille.tlf  upper.flc
 646-cn.flc   646-hu.flc   646-pt.flc   8859-7.flc   big.flf         emboss.tlf    lean.flf      script.flf     smmono12.tlf   ushebrew.flc
 646-cu.flc   646-irv.flc  646-se2.flc  8859-8.flc   bigmono12.tlf   frango.flc    letter.tlf    shadow.flf     smmono9.tlf    uskata.flc
 646-de.flc   646-it.flc   646-se.flc   8859-9.flc   bigmono9.tlf    future.tlf    mini.flf      slant.flf      smscript.flf   utf8.flc
 646-dk.flc   646-jp.flc   646-yu.flc   ascii12.tlf  block.flf       hz.flc        mnemonic.flf  small.flf      smshadow.flf   wideterm.tlf
 646-es2.flc  646-kr.flc   8859-2.flc   ascii9.tlf   bubble.flf      ilhebrew.flc  mono12.tlf    smascii12.tlf  smslant.flf
 646-es.flc   646-no2.flc  8859-3.flc   banner.flf   circle.tlf      ivrit.flf     mono9.tlf     smascii9.tlf   standard.flf

You can change the output font by using the below command.

toilet -f smmono9 LinuxBots
toilet-smmono9-example-image
toilet -f smblock LinuxBots
toilet-smblock-example-image

Changing the color of Output

There are two different color options available in the Toilet tool. They are called filters. There are some other options are also available in the filters option. You can list available filters by running the below command.

toilet --filter list
Available filters:
 "crop": crop unused blanks
 "gay": add a rainbow colour effect
 "metal": add a metallic colour effect
 "flip": flip horizontally
 "flop": flip vertically
 "180": rotate 180 degrees
 "left": rotate 90 degrees counterclockwise
 "right": rotate 90 degrees clockwise
 "border": surround text with a border

You change the color of output by running this command.

toilet --filter gay LinuxBots
m        "                         mmmmm           m            #      mmm    m mm   m   m  m   m  #    #  mmm   mm#mm   mmm    #        #    #"  #  #   #   #m#   #mmmm" #" "#    #    #   "   #        #    #   #  #   #   m#m   #    # #   #    #     """m   #mmmmm mm#mm  #   #  "mm"#  m" "m  #mmmm" "#m#"    "mm  "mmm" 
toilet --filter metal LinuxBots
 m        "                         mmmmm           m            #      mmm    m mm   m   m  m   m  #    #  mmm   mm#mm   mmm    #        #    #"  #  #   #   #m#   #mmmm" #" "#    #    #   "   #        #    #   #  #   #   m#m   #    # #   #    #     """m   #mmmmm mm#mm  #   #  "mm"#  m" "m  #mmmm" "#m#"    "mm  "mmm" 
toilet --filter border:metal LinuxBots
┌───────────────────────────────────────────────────────────────                                                                  m        "                         mmmmm           m            #      mmm    m mm   m   m  m   m  #    #  mmm   mm#mm   mmm    #        #    #"  #  #   #   #m#   #mmmm" #" "#    #    #   "   #        #    #   #  #   #   m#m   #    # #   #    #     """m   #mmmmm mm#mm  #   #  "mm"#  m" "m  #mmmm" "#m#"    "mm  "mmm"                                                                                                                                  └───────────────────────────────────────────────────────────────┘

Output in HTML or SVG format

You can export output in HTML, SVG image and many more formats using the toilet. You can get the list of all supported formats by running this command.

toilet --export list
Available export formats:
 "caca": native libcaca format
 "ansi": ANSI
 "utf8": UTF-8 with ANSI escape codes
 "utf8cr": UTF-8 with ANSI escape codes and MS-DOS \r
 "html": HTML
 "html3": backwards-compatible HTML
 "bbfr": BBCode (French)
 "irc": IRC with mIRC colours
 "ps": PostScript document
 "svg": SVG vector image
 "tga": TGA image
 "troff": troff source

Save output in HTML format by running this command

toilet --filter border:metal LinuxBots --export html > metal.html

Save output in SVG vector image by running this command

toilet --filter border:metal LinuxBots --export svg > metal.svg
toilet output in SVG

Using toilet with other commands

We can use toilet tool with other commands also. You can seed the output of below-combined commands.

echo LinuxBot | toilet -f smmono9 --gay
toilet-echo-example

Conclusion:

In this article, we learned about the installation and usage of the Figlet and Toilet command-line tool. Both tools are fun to use and has awesome features. You can mention in comments, what’s your favorite tool and feature.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *