I have created a clj command on my system (using Ruby, http://gist.github.com/247899) that will run a Clojure script or launch the REPL.
For example: "clj script.clj" or just "clj script" will run as script. You may also pass args to the Clojure script like this "clj script arg1 arg2". You may also pass arguments starting with "-X" through to Java. I also have shorthands for other things like the arg -Xjmx is converted to -Dcom.sun.management.jmxremote. Just typing clj at the command line anywhere will start a REPL. I created this when I started using Clojure to make it easier to work with and have been hacking on it for a while. I add stuff all the time for my own convenience. The basic idea is that you have a default classpath which is used when you are not working within a project. If I execute clj within a directory that contains a lib directory then it will put the jars in lib on the classpath. If there is no lib directory then it will use the default classpath. I explicitly set which jars are on the default classpath but I think a better general purpose approach would be to have a directory somewhere on your system that contains the default jars. For example groovy has the .groovy/lib dir under ~ for this purpose. This would allow you to easily add default jars without modifying the clj script. I also use a file named .cljrc.clj to configure the REPL. When the script starts it will find the nearest parent dir that contains a file named .cljrc.clj. When it finds this file it will run it and then start the java process in that directory. I usually create a default file in my root directory or ~ and one in each project. This file usually contains an exit function to shutdown the REPL but you can also configure the REPL here so that you don't have to do it each time. I created this before leiningen was available but I still use it and the two work together very well. I also configure Emacs to use this as my Clojure binary. (setq swank-clojure-binary "clj") What the others have said is still true. I only use Clojure for admin stuff when the startup time is not a factor. But this clj script takes away a lot of the pain of launching Clojure from the command line. I hope this has more signal than noise. Brenton On Feb 4, 9:35 am, Phil Hagelberg <p...@hagelb.org> wrote: > On Thu, Feb 4, 2010 at 8:33 AM, Stuart Sierra > > <the.stuart.sie...@gmail.com> wrote: > > Clojure can certainly do these things; clojure-contrib contains many > > file and io-related utilities. But remember that Clojure, like any > > Java program, takes more time to start up than "scripting" languages > > like Perl/Bash/Ruby/Python, so it may be less suitable for programs > > that you intend to run at the command-line. > > Also relevant is the fact that launching Clojure from the command-line > is very inconvenient compared to scripting languages. If you want > something simple you can just put on your path, you'll need to wrap it > in a bash (or other language) script anyway to handle the classpath, > etc. The combination of startup time and the need to roll your own > bash script even for simple things has kept me from wanting to use > Clojure as a perlish-replacement. > > -Phil -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en