4coder/build_new/helpers/print-routines.sh

61 lines
1010 B
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
colors_supported() {
# Check if stdout is a terminal
[[ -t 1 ]] || return 1
# Check if TERM is set and not "dumb"
[[ -n "$TERM" && "$TERM" != "dumb" ]] || return 1
# Check if tput is available and supports colors
if command -v tput >/dev/null 2>&1; then
tput setaf 1 >/dev/null 2>&1 || return 1
fi
return 0
}
if colors_supported; then
# Colors & Styles for output
RED='\033[0;31m'
GREEN='\033[0;32m'
BLUE='\033[0;34m'
BOLD='\033[1m'
NC='\033[0m' # No Color
else
RED=''
GREEN=''
BLUE=''
BOLD=''
NC=''
fi
print_success() {
printf "%b✓%b %s\n" "$GREEN" "$NC" "$1"
}
print_info() {
printf "%b%b%b %s\n" "$BLUE" "$BOLD" "$NC" "$1"
}
print_step() {
printf "%b===%b%b %s %b%b===%b\n" "$BLUE" "$NC" "$BOLD" "$1" "$NC" "$BLUE" "$NC"
}
print_warning() {
printf "%b⚠%b %s\n" "$YELLOW" "$NC" "$1"
}
print_error() {
printf "%b⚠%b %s\n" "$RED" "$NC" "$1"
}
pushdir() {
pushd $1 > /dev/null
}
popdir() {
popd > /dev/null
}