Skip to content

Instantly share code, notes, and snippets.

@mattryall
Created November 29, 2011 07:15
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 mattryall/1403829 to your computer and use it in GitHub Desktop.
Save mattryall/1403829 to your computer and use it in GitHub Desktop.
Shell script to launch IDEA
#!/bin/sh
# grab the latest version of IDEA
IDEA=`ls -1dt /Applications/IntelliJ\ * | head -n1`
if [ -f "$1" ]; then # first, try any filename provided
open -a "$IDEA" "$1"
elif [ -d ".idea" ]; then # second, try the .idea directory
open -a "$IDEA" "."
elif [ -f *.ipr ]; then # third, try any IDEA project files
open -a "$IDEA" `ls -1d *.ipr | head -n1`
elif [ -f pom.xml ]; then # fourth, try importing pom.xml
open -a "$IDEA" pom.xml
else # finally, just open IDEA
open "$IDEA"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment