Created
August 18, 2017 21:49
-
-
Save pozgo/45b52810e8c02beb8e58bc85a5a8da69 to your computer and use it in GitHub Desktop.
Bash Basic Functions
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
#!/usr/bin/env bash | |
# Bash Colors | |
green=$(tput setaf 2) | |
red=$(tput setaf 1) | |
white=$(tput setaf 7) | |
yellow=$(tput setaf 3) | |
blue=$(tput setaf 4) | |
purple=$(tput setaf 5) | |
cyan=$(tput setaf 6) | |
bold=$(tput bold) | |
reset=$(tput sgr0) | |
underline=$(tput sgr 0 1) | |
col=$(tput cols) | |
### Logging Functions | |
#### Mesages | |
msg() { | |
if [[ "${@}" ]]; then echo "${bold}${white}${@}${reset}"; else echo; fi | |
} | |
important() { | |
if [[ "${@}" ]]; then echo "${bold}${yellow}${@}${reset}"; else echo; fi | |
} | |
#### Statuses | |
ok() { | |
if [[ "${@}" ]]; then echo "${bold}${green}[ OK ] [`date +'%T'`]${reset} ${@}"; else echo; fi | |
} | |
warn() { | |
if [[ "${@}" ]]; then echo "${bold}${yellow}[ WARNING ] [`date +'%T'`]${reset} ${@}"; else echo; fi | |
} | |
err() { | |
if [[ "${@}" ]]; then echo "${bold}${red}[ ERROR ] [`date +'%T'`]${reset} ${@}"; else echo; fi | |
exit 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment