Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Boilerplate for running Clojure as a shebang script
#_DEPS is same format as deps.edn. Multiline is okay.
{:deps {clj-time {:mvn/version "0.14.2"}}}
#_You can put other options here
-J-Xms256m -J-Xmx256m -J-client
exec clojure $OPTS -Sdeps "$DEPS" "$0" "$@"
(println "Hello!")
(require '[clj-time.core :as t])
(prn (str (t/now)))
(prn *command-line-args*)
(println (.. (Runtime/getRuntime)
$ cp script.clj ~/bin/cljtest2
# ~/bin is on my $PATH
$ chmod +x ~/bin/cljtest2
$ time cljtest2 "Yo" "Hey" 1 3 4 - -ff
("Yo" "Hey" "1" "3" "4" "-" "-ff")
real 0m2.073s
user 0m6.073s
sys 0m0.297s
Copy link

kevinjamescasey commented Mar 6, 2021

That is cool. Thanks for the explanations!

So you have to be a little careful about what you put between the parens on lines 2 and 16. For example I had to add quotes around the URL in this line to make the Clojure reader happy:

   #_this shebang genius is from ""

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment