Skip to content

Instantly share code, notes, and snippets.

@stubar
Last active January 29, 2021 15:09
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save stubar/98fe0ad0e8adc96483e03e1d3ae72df8 to your computer and use it in GitHub Desktop.
Save stubar/98fe0ad0e8adc96483e03e1d3ae72df8 to your computer and use it in GitHub Desktop.
Fix for Jetbrains Toolbox file extension issue

Fix for Jetbrains Toolbox file extension issue

Details of issue here https://youtrack.jetbrains.com/issue/TBX-2540

When Jetbrains Toolbox auto updates PHPStorm, it creates a new app in a new location rather than overwriting the same location. This means file associations are lost everytime you update. This script aims to re add your file extensions everytime Toolbox updates PHPStrom.

brew install duti

Copy the following to a sh file somewhere e.g. /some-path/phpfix.sh. Edit to taste.

duti -s com.jetbrains.PhpStorm tsx all
duti -s com.jetbrains.PhpStorm ts all
duti -s com.jetbrains.PhpStorm js all
duti -s com.jetbrains.PhpStorm json all
duti -s com.jetbrains.PhpStorm md all

chmod +x /some-path/phpfix.sh

touch ~/Library/LaunchAgents/phpStorm.fix

Copy the following to ~/Library/LaunchAgents/phpStorm.fix

<?xml version=“1.0” encoding=“UTF-8”?>
<!DOCTYPE plist PUBLIC “-//Apple//DTD PLIST 1.0//EN” “http://www.apple.com/DTDs/PropertyList-1.0.dtd”>
<plist version=“1.0”>
<dict>
        <key>Label</key>
        <string>phpStorm.fix</string>
        <key>ProgramArguments</key>
        <array>
                <string>/some-path/phpfix.sh</string>
        </array>
        <key>WatchPaths</key>
        <array>
                <string>/Users/<YOUR_MAC_USER>/Applications/JetBrains\ Toolbox/PhpStorm.app/Contents/Info.plist</string>
        </array>
</dict>
</plist>

launch the above plist. launchctl load ~/Library/LaunchAgents/phpStorm.fix

References

https://apple.stackexchange.com/questions/91522/change-file-association-in-terminal https://github.com/moretension/duti

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment