diff --git a/bin/run b/bin/run index db12913..9bb1fa4 100755 --- a/bin/run +++ b/bin/run @@ -23,6 +23,8 @@ else exit 1 fi +configure_environment + while true; do if [[ $# == 0 ]]; then printf "\nUsage: run OPTION\n" diff --git a/lib/utilities.sh b/lib/utilities.sh index 8797702..31d76b4 100644 --- a/lib/utilities.sh +++ b/lib/utilities.sh @@ -101,3 +101,18 @@ get_install_root() { esac } export -f get_install_root + +# Configures shell for new machines and ensures PATH is properly configured for running scripts. +# Parameters: None. +configure_environment() { + if [[ ! -s "$HOME/.bash_profile" ]]; then + printf "%s\n" "if [ -f ~/.bashrc ]; then . ~/.bashrc; fi" > "$HOME/.bash_profile" + fi + + if [[ ! -s "$HOME/.bashrc" ]]; then + printf "%s\n" 'export PATH="/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"' > "$HOME/.bashrc" + fi + + export PATH="/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/opt/homebrew/sbin:/usr/local/sbin:/usr/sbin:/sbin:$PATH" +} +export -f configure_environment