Skip to content

Instantly share code, notes, and snippets.

@glensc
Last active May 17, 2017 09:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save glensc/74d9bf09855fd9a4164b6bb5fa6bbfed to your computer and use it in GitHub Desktop.
Save glensc/74d9bf09855fd9a4164b6bb5fa6bbfed to your computer and use it in GitHub Desktop.
PHPStorm Launch Wrapper

PHPStorm Launch Wrapper

Wrapper that allows to open projects from commandline:

$ phpstorm ~/projects/awesome-project

Download this snippet and install into your $PATH

This command only takes care of opening directories. If you need to have diff option, etc command passing, write your own.

#!/bin/sh
# expand paths to be absolute if specified
if [ -n "$1" ]; then
set -- "$(realpath "$@")"
fi
app='/Applications/PhpStorm.app'
if [ ! -d "$app" ]; then
# Try JetBrains Toolbox
plist="$HOME/Applications/JetBrains Toolbox/PhpStorm.app/Contents/Info.plist"
if [ -f "$plist" ]; then
# Poor man's plist parser
app=$(grep -A1 JetBrainsToolboxApp "$plist" | gsed -rne 's,.*<string>(.+)</string>,\1,p')
fi
fi
if [ ! -d "$app" ]; then
echo >&2 "$0: Can't find PhpStorm installation"
exit 1
fi
# run the application
exec open -n "$app" --args "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment