-
Notifications
You must be signed in to change notification settings - Fork 0
/
ascii.sh
executable file
·36 lines (28 loc) · 914 Bytes
/
ascii.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/sh
# ASCII image generator
# Usage: ./ascii.sh <word>
# Function to check if a package is installed
package_installed() {
apk info -e "$@" &> /dev/null
}
# Check if lolcat and figlet are installed
if ! package_installed lolcat || ! package_installed figlet; then
echo "Installing lolcat and figlet..."
# Check if testing repository is already added
if ! grep -q "http://dl-cdn.alpinelinux.org/alpine/edge/testing" /etc/apk/repositories; then
echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" | tee -a /etc/apk/repositories
apk update
fi
# Install packages
apk add lolcat figlet
fi
# Get the word
word="$1"
# Check if a word was provided
if [ -z "$word" ]; then
echo "Please provide a word to generate ASCII art."
exit 1
fi
# Generate ASCII art (without color codes) and Pipe the output to lolcat for colorization
figlet -f "banner" "$word" 2>/dev/null | lolcat
echo