Skip to content

Instantly share code, notes, and snippets.

@timnew
Last active March 1, 2023 05:11
Show Gist options
  • Save timnew/9a570de34e2016c3994f70207e23a250 to your computer and use it in GitHub Desktop.
Save timnew/9a570de34e2016c3994f70207e23a250 to your computer and use it in GitHub Desktop.
Activate SDK from a bunch of installed ones
#!/usr/bin/env bash
# How to use
# 1. Put all unzipped SDKs into a folder
# 2. Put this file in the same folder
# 3. Update the `SYMOLIC_LINK` value to the one reffered by $PATH
# 4. call this script from anywhere, it would list all SDKs, and recreate the $SYMOLIC_LINK to the selected SDK
SYMOLIC_LINK=~/Workspace/flutter
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
cd $SCRIPT_DIR
prompt="Please select a SDK:"
options=( $(ls -d */) )
PS3="$prompt "
select opt in "${options[@]}" "Quit" ; do
if (( REPLY == 1 + ${#options[@]} )) ; then
exit
elif (( REPLY > 0 && REPLY <= ${#options[@]} )) ; then
echo "You picked $opt"
break
else
echo "Invalid option. Try another one."
fi
done
echo "Remove old symolic link"
rm $SYMOLIC_LINK
echo "Create new symbolic link to $opt"
ln -s $SCRIPT_DIR/$opt $SYMOLIC_LINK
echo "Done"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment