Skip to content

Instantly share code, notes, and snippets.

@icecoobe
Created May 6, 2023 01:53
Show Gist options
  • Save icecoobe/8a353191a77c655a5d9f9939cec17bf1 to your computer and use it in GitHub Desktop.
Save icecoobe/8a353191a77c655a5d9f9939cec17bf1 to your computer and use it in GitHub Desktop.
output information to console under shell
#!/bin/bash
##############################################################################
# Print information to stdout in bold green style
# Globals:
# None
# Arguments:
# None
# Outputs:
# Writes information to stdout
##############################################################################
function info()
{
local FG_BGREEN='\e[1;32m'; # Foreground in Bold White
local RESET_COLOR='\e[0m' # Text Reset
echo -e "${FG_BGREEN}[$(date +'%Y-%m-%d %H:%M:%S%z')]: $* ${RESET_COLOR}" >&1
}
##############################################################################
# Print error information to stderr in bold red style
# Globals:
# None
# Arguments:
# None
# Outputs:
# Writes infomation to stderr
##############################################################################
function err()
{
local FG_BRED='\e[1;31m'; # Foreground in Bold Red
local BG_HI_RED='\e[0;101m'; # High Intensity Backgrounds (in red)
local RESET_COLOR='\e[0m' # Text Reset
echo -e "${FG_BRED}${BG_HI_RED}[$(date +'%Y-%m-%d %H:%M:%S%z')]: $* ${RESET_COLOR}" >&2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment