Skip to content

Instantly share code, notes, and snippets.

@utisam
Last active February 6, 2024 02:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save utisam/7d06e75c1f9a7620b7020207881f1778 to your computer and use it in GitHub Desktop.
Save utisam/7d06e75c1f9a7620b7020207881f1778 to your computer and use it in GitHub Desktop.
fvm-activate
# 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