-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
45 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Define color codes | ||
declare -A COLORS | ||
COLORS[black]="0;30" | ||
COLORS[red]="0;31" | ||
COLORS[green]="0;32" | ||
COLORS[yellow]="0;33" | ||
COLORS[blue]="0;34" | ||
COLORS[magenta]="0;35" | ||
COLORS[cyan]="0;36" | ||
COLORS[white]="0;37" | ||
COLORS[gray]="0;90" | ||
|
||
# Function to print colored text | ||
cprint() { | ||
local text="$1" | ||
local color="$2" | ||
|
||
# Get color code from COLORS array | ||
local color_code=${COLORS[$color]} | ||
|
||
# Check if color code exists | ||
if [[ -z "$color_code" ]]; then | ||
echo "Error: Color '$color' not supported." | ||
return 1 | ||
fi | ||
|
||
# Print text with color | ||
echo -e "\033[${color_code}m$text\033[0m" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters