Quickly try out Clojure and libraries on rebel-readline:
This README is aimed at people starting their Clojure journey as well as Clojure experts. If anything is not clear, or you learned something that might help other starters, please open an issue or start a new discussion 🌸
This tool targets both Clojure newcomers as well as Clojure experts.
Trying out Clojure is easier when you have code completion, syntax highlighting and function documentation and examples nearby. deps-try
provides a REPL with exactly these IDE functionalities (and some more).
This means there's no need to install or configure any Clojure plugins/extensions for your editor. Also you don't need to setup a project this way, so instead of diving into the nitty gritty details of a deps.edn
configuration file, you can start writing Clojure.
Adding maven/git/local-libraries can be done using a convenient notation:
$ deps-try some-maven/library com.github.user/a-git-project ~/some/local/project
# add additional libraries during a REPL-session (no restart needed)
users=> :deps/try another/library "https://github.com/seancorfield/next-jdbc" "../other/local/project"
Again, no need to setup or adjust a project, or type out the full configuration at the command line.
The easiest way to start.
# latest stable
$ docker run -it --pull always ghcr.io/eval/deps-try
# unstable (i.e. master branch)
$ docker run -it --pull always ghcr.io/eval/deps-try:unstable
See -h
or Usage for detailed options.
$ brew install eval/brew/deps-try
# For future upgrades do:
$ brew update && brew upgrade deps-try
There's also the unstable releases (the latest master):
$ brew install --head eval/brew/deps-try
# For future upgrades do:
$ brew update && brew reinstall deps-try
bbin allows for easy installation of Babashka scripts (such as deps-try).
It's currently the only way to install deps-try on Windows.
$ bbin install https://github.com/eval/deps-try/releases/download/stable/deps-try-bb.jar --as deps-try
# or the unstable version (latest master)
$ bbin install https://github.com/eval/deps-try/releases/download/unstable/deps-try-bb.jar --as deps-try-unstable
# Check version
$ deps-try -v
# Re-run the install command to upgrade
#!/usr/bin/env sh
exec bb /absolute/path/to/deps-try-bb.jar "$@"
## Usage
```bash
$ deps-try -h
A CLI to quickly try Clojure (libraries) on rebel-readline.
VERSION
v0.12.0
USAGE
$ deps-try [dep-name [dep-version] [dep2-name ...] ...] [--recipe[-ns] recipe]
OPTIONS
dep-name
dependency from maven (e.g. `metosin/malli`, `org.clojure/cache`),
git (e.g. `com.github.user/project`, `ht.sr.user/project`,
`https://github.com/user/project`, `https://anything.org/user/project.git`),
or a local folder containing a file `deps.edn` (e.g. `.`,
`~/projects/my-project`, `./path/to/project`).
dep-version (optional)
A maven version (e.g. `1.2.3`, `LATEST`) or git ref (e.g. `some-branch`,
`v1.2.3`).
The id of a PR or MR is also an acceptable version for git deps (e.g. `^123`).
When not provided, `LATEST` is implied for maven deps and the latest SHA
of the default-branch for git deps.
--recipe, --recipe-ns
Name of recipe (see recipes command) or a path or url to a Clojure file.
The REPL-history will be seeded with the (ns-)steps from the recipe.
EXAMPLES
;; The latest version of malli from maven, and git-tag v1.3.894 of the next-jdbc repository
$ deps-try metosin/malli io.github.seancorfield/next-jdbc v1.3.894
COMMANDS
recipes list built-in recipes (`recipes --refresh` to update)
This feature was sponsored by Clojurists Together ✨ in Q3-2023.
Read all about recipes here.
Binding | Comment | |
---|---|---|
TAB / Ctrl + I | Indent or complete. | |
Ctrl + X Ctrl + A | Apropos. Search all public vars in loaded namespaces matching word before cursor. | |
Ctrl + X Ctrl + D | Show doc of function (or namespace) using word before cursor. | |
Ctrl + X Ctrl + E | Eval expression before cursor. | |
Ctrl + X Ctrl + T | Eval expression before cursor and tap> the result (taps the last result/exception on empty line). |
|
Ctrl + X Ctrl + M | Force accept line (when cursor is in a position where Return would insert a newline). | |
Ctrl + X Ctrl + S | Show source of function using word before cursor. | |
Ctrl + X Ctrl + X | Searches clojuredocs for examples using word before cursor. | |
Ctrl + R Search term Ctrl + R (backward) / Ctrl + S (forward) | Searches history for commands containing Search term | |
Esc/Alt + Return | Insert newline (where Return would otherwise submit line). | |
Code + ↑ | Searches history for lines starting with Code (e.g. find all requires, defs etc). | |
Alt + p / Alt + n | Step back-/forward through history without stepping through every line of a history item (as ↑/↓ do). |
I got you:
$ clojure -Sdeps '{:deps {com.github.eval/deps-try {:deps/root "vendor/rebel-readline/rebel-readline" :git/sha "3781e67c3afae3b51f414db1b12abe5ff33d480b"}}}' -m rebel-readline.main
Big thanks to Bruce Hauman and contributors for creating rebel-readline 🌸.
While the GitHub contributors page now only shows a meager 1 commit from Bruce Hauman, this couldn't be farther from the truth obviously.
Big thanks to Avery Quinn for coming up with lein-try which inspired the creation of this project (once tools-deps came out).
Copyright (c) 2024 Gert Goet, ThinkCreate. Distributed under the MIT license. See LICENSE.
Code in vendor/rebel-readline originates from rebel-readline which is covered by the Eclipse Public License either version 1.0 or (at your option) any later version.