-
-
Save dobe/12c6a989f481d9e9769cefb0fea8271c to your computer and use it in GitHub Desktop.
intellij wrapper around the idea cli script which searches for the project in parent dirs
This file contains hidden or 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
#!/usr/bin/env bash | |
set -e | |
target=${1:-"$PWD"} | |
target=$(realpath "$target") | |
if [ -d "$target" ] | |
then | |
cd "$target" | |
else | |
if [ -f "$target" ] | |
then | |
cd $(dirname "$target") | |
target_file=$target | |
else | |
echo "$target" is not a file or a directory && exit 1 | |
fi | |
fi | |
while [ ! -d .idea ] | |
do | |
cd .. | |
if [ $(pwd) = "/" ] | |
then | |
if [ -n "$target_file" ] | |
then | |
# start idea with file argument only and let if find the open project if one exists | |
idea "$target_file" | |
exit 0 | |
else | |
echo "no project found" && exit 1 | |
fi | |
fi | |
done | |
idea "$PWD" "$target_file" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment