Skip to content

Instantly share code, notes, and snippets.

@shadiabuhilal
Created February 2, 2024 09:58
Show Gist options
  • Save shadiabuhilal/e08d0b41441ddf54d5830d0de14cf3df to your computer and use it in GitHub Desktop.
Save shadiabuhilal/e08d0b41441ddf54d5830d0de14cf3df to your computer and use it in GitHub Desktop.
text formatting in bash script
#!/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