Created
August 2, 2023 02:33
-
-
Save CalebMacdonaldBlack/882f53d8e75175dbcdaaa0ac268565ba to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
if [ "$(TERM=xterm tput sgr0 2>/dev/null)" ]; then | |
export TERM=xterm | |
txtund=$(tput sgr 0 1) # Underline | |
txtbld=$(tput bold) # Bold | |
blu=$(tput setaf 4) # Blue | |
grn=$(tput setaf 2) # Green | |
red=$(tput setaf 1) # Red | |
bldblu=${txtbld}$(tput setaf 4) # Bold Blue | |
bldgrn=${txtbld}$(tput setaf 2) # Bold Green | |
bldred=${txtbld}$(tput setaf 1) # Bold Red | |
txtrst=$(tput sgr0) # Reset | |
txttab=$(printf '\t') # Tab | |
else | |
txtund="" | |
txtbld="" | |
blu="" | |
grn="" | |
red="" | |
bldblu="" | |
bldgrn="" | |
bldred="" | |
txtrst="" | |
txttab=$(printf '\t') | |
fi | |
function log_context() { | |
basename `git rev-parse --show-toplevel` | |
} | |
function abort_on_error() { | |
if [[ $? -ne 0 ]]; then | |
echo_error "$1" | |
exit 1 | |
fi | |
} | |
function echo_error() { | |
echo "${bldred}[$(log_context)]${txtrst} ${red}$1${txtrst}" | |
} | |
function echo_message() { | |
echo "${bldgrn}[$(log_context)]${txtrst} ${grn}$1${txtrst}" | |
} | |
function echo_info() { | |
echo "${bldblu}[$(log_context)]${txtrst} ${blu}$1${txtrst}" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment