Created
February 2, 2024 09:58
-
-
Save shadiabuhilal/e08d0b41441ddf54d5830d0de14cf3df to your computer and use it in GitHub Desktop.
text formatting in bash script
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
#!/bin/bash | |
# Function to format text as bold | |
boldText() { | |
tput bold | |
echo "$@" | |
tput sgr0 | |
} | |
# Function to default color text as white | |
defaultText() { | |
tput setaf 97 | |
echo "$@" | |
tput sgr0 | |
} | |
# Function to success color text with green | |
successText() { | |
tput setaf 2 | |
echo "$@" | |
tput sgr0 | |
} | |
# Function to info color text with blue | |
infoText() { | |
tput setaf 4 | |
echo "$@" | |
tput sgr0 | |
} | |
# Function to error color text with red | |
errorText() { | |
tput setaf 1 | |
echo "$@" | |
tput sgr0 | |
} | |
# Usage exmaple for bold text: | |
echo $(boldText "Reading $ENV_FILE file.") | |
# Usage exmaple for bold text and success color: | |
echo $(boldText "$(successText "[DONE]:") Reading $ENV_FILE file.") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment