forgejo-runner-services/pretty_print

39 lines
536 B
Bash
Executable file

#!/bin/bash
# Usage: pretty_print [--no-newline] <text> <color_name> [<bold>]
pretty_print() {
local colour=""
local bold=""
local newline="\n"
if [ "$1" = "--no-newline" ]; then
newline=""
shift
fi
if [ -n "$2" ]; then
colour="$2"
fi
if [ "$3" = "bold" ]; then
bold="\e[1m"
fi
case "$colour" in
red)
colour="\e[31m"
;;
green)
colour="\e[32m"
;;
yellow)
colour="\e[33m"
;;
blue)
colour="\e[34m"
;;
*)
colour="\e[0m" # Reset
;;
esac
echo -ne "${colour}${bold}$1\e[0m$newline"
}