Last active
May 1, 2023 10:58
-
-
Save YourFriendCaspian/1288f1d64c66f74aabf6f8f60196c6ca to your computer and use it in GitHub Desktop.
.bashrc.d /.init.sh for directory based bashrc with "Colorful logging helper"
This file contains 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 | |
# Originally from detro (Ivan De Marino) | |
# https://github.com/detro/.bashrc.d/blob/master/.init.sh | |
THIS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &>/dev/null && pwd )" | |
# Common utilities | |
case "${OSTYPE}" in | |
solaris*) OSNAME="SOLARIS" ;; | |
darwin*) OSNAME="MACOSX" ;; | |
linux*) OSNAME="LINUX" ;; | |
bsd*) OSNAME="BSD" ;; | |
msys*) OSNAME="WINDOWS" ;; | |
*) OSNAME="${OSTYPE}" ;; | |
esac | |
# Source all the 'bashrc.d' files | |
for BASHRC_D_FILE in `ls ${THIS_DIR}/*.sh`; do | |
source $BASHRC_D_FILE | |
done | |
# Colorful logging helper: INFO (green) level | |
function info() { | |
echo -e "\e[32m*\e[39m ${*}" | |
} | |
# Colorful logging helper: WARN (orange) level | |
function warn() { | |
echo -e "\e[33m*\e[39m ${*}" | |
} | |
# Colorful logging helper: ERROR (red) level | |
function error() { | |
echo -e "\e[31m*\e[39m ${*}" | |
} | |
# Colorful logging helper: just a new line | |
function nln() { | |
echo "" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Changed shebang to #!/usr/bin/env bash