How to Create ASCII Text Banners in Terminal?


Have you ever wanted to add a touch of creativity and fun to your terminal experience? One way to do so is by creating ASCII text banners in your terminal. ASCII art has been around since the early days of computers and can add a unique and personal touch to your command line interface.

In this article, we'll explore how to create ASCII text banners in your terminal using a tool called FIGlet. We'll cover how to install and use FIGlet to generate customized ASCII banners with different fonts, sizes, and styles. Whether you're a seasoned command line user or just starting out, creating ASCII text banners is a fun and easy way to add some personality to your terminal.

One simple way to create an ASCII text banner is by using a tool called FIGlet. FIGlet is a command-line utility that generates text banners and ASCII art from input text.

To use FIGlet, first, make sure it is installed on your system. By using the packet manager you can install it for your distribution.

For example, you can install FIGlet using the below command 

sudo apt-get install figlet

The following installation command will give the terminal output look like this 

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  fonts-figlet
Suggested packages:
  figlet-doc
The following NEW packages will be installed:
  figlet fonts-figlet
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 261 kB of archives.
After this operation, 929 kB of additional disk space will be used.
Do you want to continue? [Y/n] 

After installing FIGlet, the tool can be used to create ASCII text banners and art from any input text. The basic method of using FIGlet is to provide the text that you want to transform into a banner as an argument to the command. For example, to create an ASCII banner for the text "Hello, World!".

Enter the following command to perform the same −

Input

figlet Hello

When executed, FIGlet will generate an ASCII banner for the input text and display it in your terminal. The output may vary depending on the font and size of the banner you've chosen. With FIGlet, you can create unique and customized ASCII banners to add a fun and creative touch to your command line experience.

Output

 _    _      _ _
| |  | |    | | |
| |__| | ___| | | ___
|  __  |/ _ \ | |/ _ \
| |  | |  __/ | | (_) |
|_|  |_|\___|_|_|\___/

1. Set Output Justification

The -a option is used to set the output justification of the ASCII banner text. You can specify whether you want the text to be aligned to the left, center or right of the output window. Here is the syntax for using the -a option:

$ figlet -a <left/center/right> <text>

Here, the <left/center/right> argument specifies the alignment of the text, and the <text> argument specifies the text that you want to display as the ASCII banner.

To illustrate this concept, let's consider an example. Imagine you want to generate an ASCII banner that showcases the phrase "Hello, World!" and aligns it to the center.

Use the following command for the execution of this −

$ figlet -a center Hello, World!

The output will be as follows −

Hello, World!

As you can see, the text is centered within the output window.

Similarly, if you want the text to be aligned to the left or right, you can use the following commands 

$ figlet -a left Hello, World!
Output:
Hello, World!
$ figlet -a right Hello, World!

Output:
Hello, World!

In this way, you can use the -a option to set the output justification of the ASCII banner text to left, center, or right.

2. Change Output Font

To modify the font style, simply utilize the -f option followed by the name of your preferred font. As an illustration, if you type the command figlet -f slant Congratulations!, to generate the ASCII text banner for the word "Congratulations!" the "slant" font will be used.

Here are a few examples of different font styles that you can use −

  • Banner Font

$ figlet -f banner Hello, World!

Output

######                                         
 #     # #   # #    # #####   ####  #####  ###### 
 #     #  # #  ##   # #    # #    # #    # #      
 ######    #   # #  # #    # #    # #    # #####  
 #         #   #  # # #    # #    # #####  #      
 #         #   #   ## #    # #    # #   #  #      
 #          # #     # #####   ####  #    # ###### 
  • Block Font

$ figlet -f block Hello, World!

Output

 _  _     ___     ____   ____     ____   ____  
/ )( \   / __)   (_  _) (    \   / ___) / ___) 
) \/ (  ( (__     _)(_   ) D (   \___ \ \___ \ 
\____/   \___)   (____) (____/   (____/(____/ 
  • Slant Font

$ figlet -f slant Hello, World!

Output

    __ __           __        __                     
   / //_/_ _____  / /_ ___  / /____  _________  ___ 
  / ,< / // / _ \/ __// -_)/ __/ _ \/ ___/ __/ |/ _ \
 /_/|_|\_,_/ .__/\__/ \__/ \__/\___/_/  /_/  |___/  
           /_/                                      

You can experiment with different fonts to create a banner that suits your preferences. To see a list of available fonts, use the command figlet -list.

3. Read Input from a File

You can read the input from a file using the -f option. This is particularly useful when you have a large amount of text to display, or when you want to create banners that are more complex than what you can create by typing text directly into the terminal.

To use this option, you need to create a file with the text you want to display. For example, let's say you have a file called my_banner.txt with the following contents:

Welcome to my ASCII text banner!

It's easy to create banners with figlet.

Just type your text, and let figlet do the rest!

To display this text as an ASCII text banner, you can use the following command:

$ figlet -f banner -c -w 80 -p < my_banner.txt

Here's what each of the options does −

  • -f banner  sets the font to the "banner" font, which is a good choice for larger text.

  • -c  centers the text horizontally.

  • -w 80  sets the output width to 80 characters, which is a good default width for most terminals.

  • -p  preserves the spacing between lines in the input file.

The < symbol is used to redirect the contents of the my_banner.txt file to the figlet command as input.

The resulting display would resemble something along these lines −

       ____   ___  ____ ____ ____ ____   ____ ____ ____ 
      / ___| / _ \/ ___/ ___|___ \___ \ / ___/ ___|___ \
     | |  _ | | | \___ \___ \ __) |__) | |  _| |     __) |
     | |_| || |_| |___) |__) |/ __/|__ < | |_| |___ / __/ 
      \____(_)___/|____/____//_____|___/ \____|____|_____|

       Welcome to my ASCII text banner!       
 It's easy to create banners with figlet.   
 Just type your text, and let figlet do the rest! 

As you can see, the -p option preserves the spacing between lines in the input file, which helps to maintain the formatting of the original text.

4. Add Space between Output Characters

You can add space between output characters using the -k option. Here is an

Example

$ figlet -k Congratulations!

Output

 C o n g r a t u l a t i o n s ! 

5. Define Output Width

You can define the output width using the -w option. Here is an example.

Example

$ figlet -f slant -w 60 Congratulations!

Output

  ___ _         _       _               __ _         _     _
 / __(_)___    (_)___  | |_ ___ _ __   / /(_)__     (_)___| |_
/ /  | / __|  | / __| | __/ _ \ '__| / / | |\ \ /\ / / / __| __|
\ \  | \__ \_ | \__ \

Conclusion

In conclusion, creating ASCII text banners in a terminal is an easy and unique way to add flair to your command line output. With the figlet command, you can produce text banners in various fonts and styles, and customize the output according to your preferences. From adjusting the font to changing the output width and adding spacing, many options are available to help you create more elaborate banners.

You can produce typical and visually tempting banners that are guaranteed to leave a lasting impact by experimenting with various fonts and options. Whether you're creating banners for personal or professional projects, the figlet command offers a versatile and practical toolset to work with. So, why not give it a go and inject some personality into your terminal output? With a bit of creativity, you can transform your plain text into eye-catching banners that will make your work stand out.

Updated on: 27-Jul-2023

977 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements