I'd like to run an interactive CLI program from within Clojure (e.g., vim) and be able to interact with it.
In bash and other programming languages, I can do that with
vim > `tty`
I tried to do the same in Clojure:
(require '[clojure.java.shell :as shell])
(shell/sh "vim > `tty`")
but it just opens vim without giving me tty.
Background: I'm developing a Clojure CLI tool which parses emails and lets a user edit the parsed data before saving them on the disk. It works the following way:
- Read a file with email content and parse it. Each email is stored as a separate file.
- Show a user the parsed data and let the user edit the data in vim. Internally I create a temporary file with the parsed data, but I don't mind doing it another way if that would solve my issue.
- After a user finished editing the parsed data (they might decide to keep it as it is) append the data to a file on a disk. So all parsed data are saved to the same file.
- Go to 1st step if there are any files with emails left.
fireplace(or (System/getenv "EDITOR") "vim")on the file; then read the file in your program when the user has saved the file and closed their editor. This is howgit commitworks.vimor any other editor from within Clojure program while also letting a user interact with this editor.