|
| 1 | +# |
| 2 | +# This file must be used by invoking "source activate.sh" from the command line. |
| 3 | +# You cannot run it directly. |
| 4 | +# To exit from the environment this creates, execute the 'deactivate' function. |
| 5 | + |
| 6 | +_MAGENTA="\033[0;95m" |
| 7 | +_YELLOW="\033[0;33m" |
| 8 | +_RESET="\033[0m" |
| 9 | + |
| 10 | +deactivate () { |
| 11 | + |
| 12 | + # reset old environment variables |
| 13 | + if [ ! -z "${_OLD_PATH:-}" ] ; then |
| 14 | + export PATH="$_OLD_PATH" |
| 15 | + unset _OLD_PATH |
| 16 | + fi |
| 17 | + |
| 18 | + if [ ! -z "${_OLD_PS1:-}" ] ; then |
| 19 | + export PS1="$_OLD_PS1" |
| 20 | + unset _OLD_PS1 |
| 21 | + fi |
| 22 | + |
| 23 | + # This should detect bash and zsh, which have a hash command that must |
| 24 | + # be called to get it to forget past commands. Without forgetting |
| 25 | + # past commands the $PATH changes we made may not be respected |
| 26 | + if [ -n "${BASH:-}" ] || [ -n "${ZSH_VERSION:-}" ] ; then |
| 27 | + hash -r 2>/dev/null |
| 28 | + fi |
| 29 | + |
| 30 | + unset DOTNET_ROOT |
| 31 | + unset DOTNET_MULTILEVEL_LOOKUP |
| 32 | + if [ ! "${1:-}" = "init" ] ; then |
| 33 | + # Remove the deactivate function |
| 34 | + unset -f deactivate |
| 35 | + fi |
| 36 | +} |
| 37 | + |
| 38 | +# Cleanup the environment |
| 39 | +deactivate init |
| 40 | + |
| 41 | +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" |
| 42 | +_OLD_PATH="$PATH" |
| 43 | +# Tell dotnet where to find itself |
| 44 | +export DOTNET_ROOT="$DIR/.dotnet" |
| 45 | +# Tell dotnet not to look beyond the DOTNET_ROOT folder for more dotnet things |
| 46 | +export DOTNET_MULTILEVEL_LOOKUP=0 |
| 47 | +# Put dotnet first on PATH |
| 48 | +export PATH="$DOTNET_ROOT:$PATH" |
| 49 | + |
| 50 | +# Set the shell prompt |
| 51 | +if [ -z "${DISABLE_CUSTOM_PROMPT:-}" ] ; then |
| 52 | + _OLD_PS1="$PS1" |
| 53 | + export PS1="(`basename \"$DIR\"`) $PS1" |
| 54 | +fi |
| 55 | + |
| 56 | +# This should detect bash and zsh, which have a hash command that must |
| 57 | +# be called to get it to forget past commands. Without forgetting |
| 58 | +# past commands the $PATH changes we made may not be respected |
| 59 | +if [ -n "${BASH:-}" ] || [ -n "${ZSH_VERSION:-}" ] ; then |
| 60 | + hash -r 2>/dev/null |
| 61 | +fi |
| 62 | + |
| 63 | +echo "${_MAGENTA}Enabled the .NET Core environment. Execute 'deactivate' to exit.${_RESET}" |
| 64 | + |
| 65 | +if [ ! -f "$DOTNET_ROOT/dotnet" ]; then |
| 66 | + echo "${_YELLOW}.NET Core has not been installed yet. Run $DIR/restore.sh to install it.${_RESET}" |
| 67 | +else |
| 68 | + echo "dotnet = $DOTNET_ROOT/dotnet" |
| 69 | +fi |
0 commit comments