Clojure rlwrap setup


/ Published in: Clojure
Save to your folder(s)

Using rlwrap in order to wrap Clojure REPL (getting vi bindings & auto completion).


Copy this code and paste it in your HTML
  1. #!/bin/bash
  2.  
  3. BREAK_CHARS="(){}[],^%$#@\"\";:''|\\"
  4. CLOJURE_DIR=/home/cljuser/install/clojure
  5. CLOJURE_JAR=$CLOJURE_DIR/clojure.jar
  6. if [ $# -eq 0 ]; then
  7. rlwrap --remember -c -b $BREAK_CHARS -f $HOME/.clj_completions \
  8. java -cp $CLOJURE_JAR clojure.lang.Repl
  9. else
  10. java -cp $CLOJURE_JAR clojure.lang.Script $1 -- $@
  11. fi
  12.  
  13. ; generating the completion file
  14. (def completions
  15. (reduce concat (map (fn [p] (keys (ns-publics (find-ns p))))
  16. '(clojure.core clojure.set clojure.xml clojure.zip))))
  17.  
  18. (with-open [f (java.io.BufferedWriter. (java.io.FileWriter. (str (System/getenv "HOME") "/.clj_completions")))]
  19. (.write f (apply str (interleave completions (repeat "\n")))))

URL: http://en.wikibooks.org/wiki/Clojure_Programming/Getting_Started#Enhancing_Clojure_REPL_with_rlwrap

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.