Add vim example

This commit is contained in:
Michiel Borkent 2020-06-07 14:16:48 +02:00
parent 566eff4b94
commit f15d609b45
2 changed files with 21 additions and 0 deletions

View file

@ -307,3 +307,7 @@ META-INF/maven/borkdude/sci/pom.xml
META-INF/leiningen/borkdude/sci/project.clj META-INF/leiningen/borkdude/sci/project.clj
... ...
``` ```
### Invoke vim inside a script
See [examples/vim.clj](../examples/vim.clj).

17
examples/vim.clj Executable file
View file

@ -0,0 +1,17 @@
#!/usr/bin/env bb
(require '[clojure.java.io :as io])
(defn vim [file]
(->
(ProcessBuilder. ["vim" file])
(.inheritIO)
(.start)
(.waitFor)))
(def readme
(let [f (io/file "README.md")]
(when (not (.exists f))
(vim (.getPath f)))
(slurp f)))
(println readme)