Responsive Terminal Banners
I worked on a really simple Bash script today to check the column size of a terminal window, and then echo the appropriate ASCII art banner into the session. If you've ever used a tiling manager like Hyprland you'll see where I'm going with this.
The script itself is fairly simple:
#!/bin/bash
# Get terminal width
COLS=$(tput cols 2>/dev/null || echo "${COLUMNS:-80}")
# Banner functions
show_large_banner() {
echo " ░▒▓██████▓▒░░▒▓████████▓▒░▒▓██████████████▓▒░░▒▓██████████████▓▒░░▒▓███████▓▒░ ░▒▓██████▓▒░░▒▓███████▓▒░░▒▓████████▓▒░"
echo " ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ "
echo " ░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ "
echo " ░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░░▒▓█▓▒░▒▓███████▓▒░░▒▓████████▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓██████▓▒░ "
echo " ░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ "
echo " ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ "
echo " ░▒▓██████▓▒░░▒▓████████▓▒░▒▓█▓▒░░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓███████▓▒░░▒▓████████▓▒░"
}
show_medium_banner() {
echo " ██████╗ ██████╗ ███╗ ███╗███╗ ███╗██████╗ █████╗ ██████╗ ███████╗"
echo " ██╔════╝██╔═████╗████╗ ████║████╗ ████║██╔══██╗██╔══██╗██╔══██╗██╔════╝"
echo " ██║ ██║██╔██║██╔████╔██║██╔████╔██║██████╔╝███████║██║ ██║█████╗ "
echo " ██║ ████╔╝██║██║╚██╔╝██║██║╚██╔╝██║██╔══██╗██╔══██║██║ ██║██╔══╝ "
echo " ╚██████╗╚██████╔╝██║ ╚═╝ ██║██║ ╚═╝ ██║██║ ██║██║ ██║██████╔╝███████╗"
echo " ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═════╝ ╚══════╝"
}
show_small_banner() {
echo " ░█▀▀░▄▀▄░█▄█░█▄█░█▀▄░█▀█░█▀▄░█▀▀ "
echo " ░█░░░█/█░█░█░█░█░█▀▄░█▀█░█░█░█▀▀ "
echo " ░▀▀▀░░▀░░▀░▀░▀░▀░▀░▀░▀░▀░▀▀░░▀▀▀ "
}
show_minimal_banner() {
echo "C0MMRADE"
}
# Select banner based on terminal width
if [ "$COLS" -ge 120 ]; then
show_large_banner
elif [ "$COLS" -ge 75 ]; then
show_medium_banner
elif [ "$COLS" -ge 35 ]; then
show_small_banner
else
show_minimal_banner
fi
Then in my NixOS configuration I call the script for interactive shells only, and pipe it through lolcat for that sweet, sweet eyecandy:
# bash ASCII banner
environment.interactiveShellInit = ''
~/Scripts/banner.sh | lolcat
'';
And the result is: