Scripting Clojure

Clojure Startup time is not ideal for day to day scripting with it. But in case you do want to run Clojure scripts, it is possible.

We need to use the “lein exec” plugin to leiningen. Edit ~/.lein/profiles.clj and add these codes:

Now the next time you run any leiningen commands, it would install the plugin. You can now execute single file clojure programs by:

For more convenience, I added this to my .zshrc:

Now I can do this:

You can also use “lein exec” for shebang, like this:

Make the file executable and run it like:

Leave a Reply

Your email address will not be published. Required fields are marked *