Created
July 12, 2021 08:25
-
-
Save minamaged113/92879073e091239409f3f0ca279f09a4 to your computer and use it in GitHub Desktop.
simple bash function for displaying multicolor output.
This file contains hidden or 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
| function pcolor() { | |
| red=$'\e[1;31m' | |
| grn=$'\e[1;32m' | |
| yel=$'\e[1;33m' | |
| blu=$'\e[1;34m' | |
| mag=$'\e[1;35m' | |
| cyn=$'\e[1;36m' | |
| end=$'\e[0m' | |
| printf "${!1}%-6s\n${end}" "$2" | |
| } | |
| # Usage example | |
| # pcolor "red" "This is a red text" | |
| # Importing to another script (given that both are in the same directory) | |
| # cwd="$(dirname "$0")" | |
| # source "$cwd/pcolor.sh" | |
| # pcolor "blu" "hi, this is a blue text" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment