Skip to content

Instantly share code, notes, and snippets.

@andrzejsliwa
Last active July 24, 2018 19:55
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 andrzejsliwa/714c0c79a046738eb2fcacf34f3335cc to your computer and use it in GitHub Desktop.
Save andrzejsliwa/714c0c79a046738eb2fcacf34f3335cc to your computer and use it in GitHub Desktop.
improved idea command line launcher
function repl {
current_month=`date +%Y-%m-%B`
filepath="$HOME/Documents/repl-$current_month.cljc"
if [ ! -f $filepath ]; then
touch $filepath
fi
echo "; `date`" >> $filepath
line=`grep --regexp="$" --count "$filepath"`
idea $filepath:$line
}
function did {
filepath="$HOME/Documents/did.txt"
if [ ! -f $filepath ]; then
touch "$filepath"
fi
echo "---- `date`" >> $filepath
echo "" >> $filepath
line=`grep --regexp="$" --count "$filepath"`
idea $filepath:$line
}
#!/bin/sh
# check latest version of IDEA in Jetbrain TOOLBOX
IDEA=`ls -1d /Applications/JetBrains\ TOOLBOX/apps/IDEA-U/*/*/IntelliJ\ IDEA.app | tail -n1`
wd=`pwd`
# directory given?
if [ -d "$1" ]; then
wd=`ls -1d "$1" | head -n1`
fi
filename=`echo "$1" | cut -d ":" -f 1`
line=`echo "$1" | cut -d ":" -f 2`
if [ "$filename" = "$line" ]; then
line=1
fi
cmd=$(printf %q "$IDEA/Contents/MacOS/idea")
# file given?
if [ -f "$wd/$filename" ]; then
eval "$cmd --line $line $wd/$filename > /dev/null > /dev/null 2>&1"
elif [ -f "$filename" ]; then
eval "$cmd --line $line $filename > /dev/null > /dev/null 2>&1"
else
pushd $wd > /dev/null
if [ -d ".idea" ]; then
# .idea project given
open -a "$IDEA" .
elif [ -f *.ipr ]; then
# idea ipr project given
open -a "$IDEA" `ls -1d *.ipr | head -n1`
elif [ -f pom.xml ]; then
# maven project given
open -a "$IDEA" "pom.xml"
elif [ -f project.clj ]; then
# leiningen project given
open -a "$IDEA" "project.clj"
else
open "$IDEA"
fi
popd > /dev/null
fi
curl -L "https://gist.githubusercontent.com/andrzejsliwa/714c0c79a046738eb2fcacf34f3335cc/raw/idea" -o /usr/local/bin/idea
chmod +x /usr/local/bin/idea
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment