Last active
February 16, 2018 20:44
-
-
Save tylrd/151d5aced3df7026522fdafef2aab7c8 to your computer and use it in GitHub Desktop.
idea.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cat << "EOL" > /usr/local/bin/idea | |
#!/bin/sh | |
# check for where the latest version of IDEA is installed | |
IDEA=`ls -1d /Applications/IntelliJ\ * | tail -n1` | |
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 | |
# were we given a file? | |
if [ -f "$1" ]; then | |
# echo "opening '$1'" | |
open -a "$IDEA" "$1" | |
else | |
# let's check for stuff in our working directory. | |
pushd $wd > /dev/null | |
# does our working dir have an .idea directory? | |
if [ -d ".idea" ]; then | |
echo "opening via the .idea dir" | |
open -a "$IDEA" . | |
# is there an IDEA project file? | |
elif [ -f *.ipr ]; then | |
echo "opening via the project file" | |
open -a "$IDEA" `ls -1d *.ipr | head -n1` | |
# Is there a pom.xml? | |
elif [ -f pom.xml ]; then | |
echo "importing from pom" | |
open -a "$IDEA" "pom.xml" | |
elif [ -f build.gradle ]; then | |
echo "importing from build.gradle" | |
open -a "$IDEA" "build.gradle" | |
# can't do anything smart; just open IDEA | |
else | |
echo 'Opening IDEA' | |
open "$IDEA" | |
fi | |
popd > /dev/null | |
fi | |
EOL | |
chmod +x /usr/local/bin/idea |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment