Last active
February 6, 2024 02:52
-
-
Save utisam/7d06e75c1f9a7620b7020207881f1778 to your computer and use it in GitHub Desktop.
fvm-activate
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
# This script should be saved as $PROJECT/scripts/fvm-activate | |
if [ "${BASH_SOURCE-}" = "$0" ]; then | |
echo "You must source this script: \$ source $0" >&2 | |
return 33 | |
fi | |
fvm-deactivate() { | |
if ! [ -z "${_FVM_OLD_PATH:+_}" ] ; then | |
PATH="$_FVM_OLD_PATH" | |
export PATH | |
unset _FVM_OLD_PATH | |
fi | |
hash -r 2>/dev/null | |
if ! [ -z "${_FVM_OLD_PS1+_}" ] ; then | |
PS1="$_FVM_OLD_PS1" | |
export PS1 | |
unset _FVM_OLD_PS1 | |
fi | |
unset FVM_ENV | |
if [ ! "${1-}" = "nondestructive" ] ; then | |
unset -f fvm-deactivate | |
fi | |
} | |
# unset irrelevant variables | |
fvm-deactivate nondestructive | |
FVM_ENV=$(realpath $(dirname $0)/../.fvm/flutter_sdk) | |
if ! [ -d $FVM_ENV ]; then | |
echo "Run 'fvm install'" >&2 | |
return 34 | |
fi | |
export FVM_ENV | |
_FVM_OLD_PATH="$PATH" | |
PATH="$FVM_ENV/bin:$PATH" | |
export PATH | |
_FVM_OLD_PS1="${PS1-}" | |
PS1="(flutter $(cat $FVM_ENV/version)) ${PS1-}" | |
export PS1 | |
hash -r 2>/dev/null |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment