Skip to content

Instantly share code, notes, and snippets.

@tomaspietravallo
Last active December 31, 2023 22:57
Show Gist options
  • Save tomaspietravallo/7a61a58714b5fcd6e5ac8b140491cd97 to your computer and use it in GitHub Desktop.
Save tomaspietravallo/7a61a58714b5fcd6e5ac8b140491cd97 to your computer and use it in GitHub Desktop.
This script will automatically alias "spark" to the Meta Spark Studio CLI corresponding to the latest build found under MacOS's Applications folder
Works as long as the apps are saved with names that follow the pattern
- Meta Spark Studio vXXX.XX
- Meta Spark Studio XXX.XX
Example: Meta Spark Studio v170
#!/bin/bash
META_SPARK_VERSION=`ls ~/../../Applications | perl -ne 'm/Meta Spark Studio v?(.*)/ && print "$1\n"' | sort | tail -1` && \
if [[ ! $META_SPARK_VERSION ]]; then echo "Error: No Application version found using the pattern specified"; fi && \
META_SPARK_LATEST=`find ~/../../Applications -name "Meta Spark Studio *$META_SPARK_VERSION" -maxdepth 1` && \
if [[ ! $META_SPARK_LATEST ]]; then echo "Error: No Application path found using the pattern specified: Meta Spark Studio v?(.*)"; fi && \
META_SPARK_CLI=`echo $"META_SPARK_LATEST" | sed 's/ /\\ /g'`"/Contents/MacOS/spark"
alias spark="$META_SPARK_CLI"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment