Skip to content

Instantly share code, notes, and snippets.

@polypus74
Last active March 20, 2018 00:50
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 polypus74/c78648e1b286dec8ce28c0cfcf714a00 to your computer and use it in GitHub Desktop.
Save polypus74/c78648e1b286dec8ce28c0cfcf714a00 to your computer and use it in GitHub Desktop.
Create new sbt project with git & ensime setup
#!/usr/bin/bash
DEFAULT_TEMPLATE="sbt/scala-seed.g8"
function err {
echo "error: $1, exiting."
exit 1
}
if [[ -z "$1" ]]
then err "must supply project name as first argument"
elif [[ -e "$1" ]]
then err "$1 already exists"
elif [[ -e target ]]
then err "target file or dir exists in $PWD"
fi
START_DIR="$PWD"
PROJECT="$1"
function cleanup {
cd "$START_DIR"
rm -rf ./target "./$PROJECT"
err "aborting"
}
trap cleanup SIGINT SIGTERM
echo "$PROJECT" | sbt new ${2:-${DEFAULT_TEMPLATE}}
if [[ -e "./$PROJECT" ]]
then cd "./$PROJECT"
sbt ensimeConfig
git init
echo 'target/' > .gitignore
cd ..
fi
rm -rf ./target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment