Skip to content

Instantly share code, notes, and snippets.

@mikemackintosh
Created August 2, 2021 04:45
Show Gist options
  • Save mikemackintosh/9ba5faafa0ae331d22d72aef72cb0ef1 to your computer and use it in GitHub Desktop.
Save mikemackintosh/9ba5faafa0ae331d22d72aef72cb0ef1 to your computer and use it in GitHub Desktop.
function cd () {
local DOTENV="\033[1;38;5;220m[\033[0;38;5;214md\033[0;38;5;215mo\033[0;38;5;216mt\033[0;38;5;217me\033[0;38;5;218mn\033[0;38;5;219mv\033[1;38;5;220m]\033[0m"
if [[ -f .env ]]; then
echo "${DOTENV} Unscoping \033[38;5;243m.env\033[0m configuration"
unset $(cat .env | cut -d'=' -f1)
fi
builtin cd "$@"
if [[ -f .env ]]; then
set -o allexport
echo "${DOTENV} Sourcing environment from \033[38;5;243m.env\033[0m"
source .env
set +o allexport
fi
}
function ".."() { cd .. }
function "../.."() { cd ../.. }
function "../../.."() { cd ../../.. }
function "../../../.."() { cd ../../../.. }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment