Skip to content

Instantly share code, notes, and snippets.

@mitake
Forked from chrisdarroch/idea
Last active September 4, 2015 02:24
Show Gist options
  • Save mitake/a7d77306a570283548bb to your computer and use it in GitHub Desktop.
Save mitake/a7d77306a570283548bb to your computer and use it in GitHub Desktop.
Open a project in IntelliJ IDEA from your command line!
#!/bin/sh
# check for where the latest version of IDEA is installed
IDEA=/opt/intellij-idea-ce/bin/idea.sh
wd=`pwd`
# were we given a directory?
if [ -d "$1" ]; then
# echo "checking for things in the working dir given"
wd=`ls -1d "$1" | head -n1`
fi
# does our working dir have an .idea directory?
if [ -d ".idea" ]; then
# echo "opening via the .idea dir"
$IDEA .
# is there an IDEA project file?
elif [ -f *.ipr ]; then
# echo "opening via the project file"
$IDEA `ls -1d *.ipr | head -n1`
# Is there a pom.xml?
elif [ -f pom.xml ]; then
# echo "importing from pom"
$IDEA "pom.xml"
# can't do anything smart; just open IDEA
else
# echo 'cbf'
$IDEA
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment