How to Generate ASCII Art Text Banners in Linux Bash for Warning Messages


2 views

When working with critical operations like database deletions or production deployments, standard terminal warnings often get overlooked. ASCII art banners serve as visual interrupters that force users to pause and acknowledge potential dangers.

Here are the most reliable command-line tools for generating ASCII art from text:

# Install figlet (most common)
sudo apt-get install figlet  # Debian/Ubuntu
sudo yum install figlet      # RHEL/CentOS

# Install toilet (more decorative)
sudo apt-get install toilet

Generate a simple banner with default font:

figlet "WARNING"

Output would look like:

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

Use different fonts and styles for better visibility:

toilet -f future "DANGER" --metal

Sample output:

  ██████╗  █████╗ ███╗   ██╗ ██████╗ ███████╗██████╗ 
 ██╔════╝ ██╔══██╗████╗  ██║██╔════╝ ██╔════╝██╔══██╗
 ██║  ███╗███████║██╔██╗ ██║██║  ███╗█████╗  ██████╔╝
 ██║   ██║██╔══██║██║╚██╗██║██║   ██║██╔══╝  ██╔══██╗
 ╚██████╔╝██║  ██║██║ ╚████║╚██████╔╝███████╗██║  ██║
  ╚═════╝ ╚═╝  ╚═╝╚═╝  ╚═══╝ ╚═════╝ ╚══════╝╚═╝  ╚═╝

Here's how to integrate ASCII warnings in a dangerous operation script:

#!/bin/bash

function show_warning() {
    toilet -f mono12 -F border "!!! WARNING !!!"
    echo ""
    figlet -f slant "Production DB Wipe"
    echo ""
    echo "THIS WILL DESTROY ALL PRODUCTION DATA"
    read -p "Are you absolutely sure? (type 'nuke' to confirm): " confirm
    [[ $confirm != "nuke" ]] && exit 1
}

show_warning
# Actual dangerous commands below

List available fonts and combine with other commands:

# Show available fonts
figlist

# Colorize output
toilet -f smblock --gay "CAUTION" | lolcat

For more artistic options:

# Install boxes for framed messages
sudo apt install boxes

echo "Critical Operation" | boxes -d parchment

For Linux users looking to create eye-catching ASCII art banners directly in the terminal, there are several excellent command-line tools available. These are particularly useful for:

  • Creating warning messages in scripts
  • Generating decorative headers
  • Adding visual emphasis to console output

The most common tool is figlet, which is available in most Linux distributions:

sudo apt-get install figlet  # Debian/Ubuntu
sudo yum install figlet      # CentOS/RHEL

Basic usage example:

figlet "Hello World"

Sample output would look like:

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

Customize the output with different fonts and layouts:

figlet -f slant "Danger!"
figlet -f big "Critical"
figlet -f banner "WARNING"

To see all available fonts:

showfigfonts

For more colorful and advanced ASCII art, try toilet:

sudo apt-get install toilet
toilet -f mono12 -F metal "Production"

This would generate output with metal-style characters in a monospace font.

Here's how to create a production database warning:

#!/bin/bash

echo
figlet -f big "WARNING!"
echo
echo "You are about to delete the PRODUCTION database!"
echo
read -p "Are you absolutely sure? (y/n) " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
    # Dangerous operation here
    echo "Database deleted."
else
    echo "Operation cancelled."
fi

For persistent use, consider creating functions in your ~/.bashrc:

function warn() {
    echo
    figlet -f slant "! $1 !"
    echo
}

# Usage:
# warn "Database Operation"