broken-mobile-server/print_box.sh
arul 969e55ac42 Upload files to "/"
These are the decoration greeting script that shows information and users who are currently logged in 
decorated ascii arts and colors while ssh into mobile server.
2024-06-02 20:46:07 +00:00

25 lines
716 B
Bash

#!/bin/bash
# Function to print a decorated rectangular box with random bright color
print_box() {
local text="$(cat)"
local text_length=${#text}
local box_width=$((text_length + 4))
# Generate a random number between 0 and 7 for ANSI bright color code
local color_code=$((RANDOM % 8 + 90))
# ANSI escape codes for bright text color
local color="\e[${color_code}m"
local reset_color="\e[0m"
# Top border
echo -e "${color}$(printf '─%.0s' $(seq 1 $box_width))${reset_color}"
# Text with borders
echo -e "${color}$text${reset_color}"
# Bottom border
echo -e "${color}$(printf '─%.0s' $(seq 1 $box_width))${reset_color}"
}