Skip to content

Instantly share code, notes, and snippets.

@miner miner/ forked from cgrand/
Last active Apr 29, 2017

What would you like to do?
Launch a plain clojure repl according to project.clj without leiningen (most of the time)
# launch a clojure plain repl but with options and classpath matching project.clj
# Except when project.clj changes (and on first launch), lein is not called.
if [ ! -f "project.clj" ]; then
echo "No project.clj"
exit 1
# stat (mostly) protects against staleness of copied project dir
# in target dir to allow `lein clean` to wipe out kein caches
KEIN=target/kein-`stat -f '%i' project.clj`
if [ ! -f "$KEIN" ] || [ "project.clj" -nt "$KEIN" ] || [ $0 -nt "$KEIN" ]; then
mkdir -p `dirname "$KEIN"`
(let [p (leiningen.core.project/read)
args (@(var leiningen.core.eval/get-jvm-args) p)
cp (with-out-str (leiningen.classpath/classpath p))]
(print "ARGS=\"")
(apply print args)
(println "\"")
(print "CP=\"")
(print cp)
(println "\""))
lein update-in : assoc :eval-in :leiningen -- run -m clojure.main -e "$CODE" > "$KEIN"
source "$KEIN"
if [ -n "$EMACS" ] || [ -n "$INSIDE_EMACS" ] ; then
RLWRAP=`command -v rlwrap`
$RLWRAP java $ARGS -cp $CP clojure.main "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.