Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Start lein repl with commands from the terminal

I would like to write a shell script to start a lein repl and then provide some commands while still keeping the repl running.

For example I might want to do the equivalent of:

lein repl
(dev)
(setup)

I can pipe to the repl by echo "(dev)\n(setup)" | lein repl but the repl terminates afterwards.

Is there a way to get around this or another means of starting a repl and issuing commands from a shell script?

like image 979
user2936410 Avatar asked Oct 30 '13 12:10

user2936410


People also ask

How do I start Clojure REPL?

To start a REPL session in Eclipse, click the Menu option, go to Run As → Clojure Application. This will start a new REPL session in a separate window along with the console output.

How do I get out of Lein REPL?

Using the CLI tools You can exit the REPL by typing Ctrl+D (pressing the Ctrl and D keys at the same time).


1 Answers

(echo "(println :hello)"; cat <&0) | lein repl

This prints the command - letting the REPL process it -, then "switches back" to stdin for input. You might have to interrupt the cat call after leaving the REPL, though.

like image 176
xsc Avatar answered Sep 28 '22 12:09

xsc