I'm using FVM to manage different Flutter versions per project.
I want my shell to automatically use the Flutter SDK inside .fvm/flutter_sdk
only when I'm inside a Flutter project, but not when I'm in my home directory or its subdirectories.
Here's the logic I'm currently using in my ~/.zshrc
:
if [ -d ".fvm/flutter_sdk" ] && [[ "$PWD" != $HOME* ]]; then
export PATH="$PWD/.fvm/flutter_sdk/bin:$PATH"
fi
Now, when I’m inside a project that uses FVM:
flutter --version
...automatically uses the project’s FVM version of Flutter, without me needing to type:
fvm flutter --version