Skip to content

Instantly share code, notes, and snippets.

@suya55
Last active June 21, 2017 14:28
Show Gist options
  • Save suya55/dbbca5078401861b22b0 to your computer and use it in GitHub Desktop.
Save suya55/dbbca5078401861b22b0 to your computer and use it in GitHub Desktop.

Revisions

  1. suya55 revised this gist Oct 30, 2015. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions ij.sh
    Original file line number Diff line number Diff line change
    @@ -3,8 +3,8 @@
    # check for where the latest version of IDEA is installed
    IDEA=`ls -1d /Applications/IntelliJ\ * | tail -n1`
    wd=`pwd`
    # Setup your working directory
    working_dir=`ls -1d ~/work | head -n1`
    # Setup your working directory. Edit 'work' to your working directory.
    working_dir=`ls -1d ~/work/$1 | head -n1`

    # were we given a directory?
    if [ -d "$1" ]; then
    @@ -35,8 +35,8 @@ else
    # echo "importing from pom"
    open -a "$IDEA" "pom.xml"
    # find argument in woring directory
    elif [ -d $working_dir/$1 ]; then
    open -a "$IDEA" $working_dir/$1
    elif [ -d $working_dir ]; then
    open -a "$IDEA" $working_dir
    # can't do anything smart; just open IDEA
    else
    # echo 'cbf'
  2. suya55 revised this gist Oct 30, 2015. No changes.
  3. suya55 renamed this gist Oct 30, 2015. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  4. suya55 created this gist Oct 30, 2015.
    47 changes: 47 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,47 @@
    #!/bin/sh

    # check for where the latest version of IDEA is installed
    IDEA=`ls -1d /Applications/IntelliJ\ * | tail -n1`
    wd=`pwd`
    # Setup your working directory
    working_dir=`ls -1d ~/work | head -n1`

    # 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"
    # find argument in woring directory
    elif [ -d $working_dir/$1 ]; then
    open -a "$IDEA" $working_dir/$1
    # can't do anything smart; just open IDEA
    else
    # echo 'cbf'
    open "$IDEA"
    fi

    popd > /dev/null
    fi