Skip to content

Instantly share code, notes, and snippets.

@YourFriendCaspian
Last active May 1, 2023 10:58
Show Gist options
  • Save YourFriendCaspian/1288f1d64c66f74aabf6f8f60196c6ca to your computer and use it in GitHub Desktop.
Save YourFriendCaspian/1288f1d64c66f74aabf6f8f60196c6ca to your computer and use it in GitHub Desktop.
.bashrc.d /.init.sh for directory based bashrc with "Colorful logging helper"
#!/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 ""
}
@YourFriendCaspian
Copy link
Author

Changed shebang to #!/usr/bin/env bash

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment