Development incubator for Babashka scripts. This is where I develop scripts in Clojure and then run them with Babashka.
I gave a presentation about writing scripts in Babashka. Slides are here.
- highlight - Highlight regex matches in piped text.
- empath - Print out and edit
$PATH
-like things. - ftime - Print out a human-readable time based on passing in millis.
- penv - Prints out the environment like
env
does, but it masks variables that it thinks are private (likeSLACK_TOKEN
). - comb - Template data using comb.
If you only want to use one of the scripts, just download it out of the
uberscripts directory and put it in a directory on your
$PATH
.
bbin is a great way to install Babashka scripts with one command.
It doesn't yet support picking
which script you want when a repo (like this one) supports multiple, so use the
following syntax (provide --main-opts
and --as
):
bbin install io.github.justone/bb-scripts --main-opts '["-m" "empath"]' --as empath
Refer to the bbin docs for more options.
Before you begin development, you should have the following installed on your PATH:
To create a script, you need to create two files. For instance, to create a new script called foo
, create the following files:
script/foo
- a Babashka dev runner
#!/usr/bin/env bb
(require '[babashka.deps :as deps])
(deps/add-deps '{:deps {justone/bb-scripts {:local/root "."}}})
(require '[foo])
(when (= *file* (System/getProperty "babashka.file"))
(apply foo/-main *command-line-args*))
src/foo.clj
- the Clojure source for the script
(ns foo)
(defn -main [& args]
(println "foo"))
Start a repl with clojure -X:clj:repl
. This will expose nREPL and pREPL ports
for editor integration. This allows for full iterative REPL-driven development.
To test running the script as a whole, use either of the following:
./script/foo [args]
- to test running in Babashkaclojure -M:clj -m foo [args]
- to test running in Clojure
To run tests with Babashka:
bb test
To run tests with Clojure:
clojure -M:clj:test
Babashka can combine all namespaces used by a script into one file called an uberscript. There is a script in ./scripts/uberscriptify
that will combine this with the proper header. To create an uberscript from the foo
script, just run:
./scripts/uberscriptify --script foo
And the resulting file will be in uberscripts/foo
.