Skip to content

Instantly share code, notes, and snippets.

@daz
Created April 11, 2023 11:00
Show Gist options
  • Save daz/270aaf640d4d87dd7e4c32a58094a0f6 to your computer and use it in GitHub Desktop.
Save daz/270aaf640d4d87dd7e4c32a58094a0f6 to your computer and use it in GitHub Desktop.
Open or switch to Fusion360
#!/bin/bash
# This will switch to Fusion 360 if it is running, or open it if it is not running.
#
# Fusion360 on Mac opens from the path "~/Applications/Autodesk Fusion 360.app"
# but it's essentially an alias and it runs as
# "~/Library/Application Support/Autodesk/webdeploy/production/{hash}/Autodesk Fusion 360.app"
# The hash, and therefore the path, changes with each update, so you can get
# double instances if it updates while running and you try to switch to it.
# Check if Fusion 360 is running
FUSION360_PS=$(ps aux | grep 'Autodesk Fusion 360.app' | grep -v grep)
if [ -z "$FUSION360_PS" ]; then
echo "Fusion 360 is not running, opening..."
open -a "Autodesk Fusion 360"
exit 0
fi
# Trim first 11 columns, so we get the path to the app
FUSION360_PS_PATH=$(echo $FUSION360_PS | awk '{ORS=" "; for(i=11;i<=NF;i++) print $i}')
# Trim everything after .app but keep .app
FUSION360_APP=$(echo $FUSION360_PS_PATH | sed 's/\.app.*$/.app/')
# Open the app
echo "Fusion 360 is running, switching to..."
open -a "$FUSION360_APP" --args -switch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment