diff --git a/doc/examples.md b/doc/examples.md index 0f4f695f..ecf19752 100644 --- a/doc/examples.md +++ b/doc/examples.md @@ -307,3 +307,7 @@ META-INF/maven/borkdude/sci/pom.xml META-INF/leiningen/borkdude/sci/project.clj ... ``` + +### Invoke vim inside a script + +See [examples/vim.clj](../examples/vim.clj). diff --git a/examples/vim.clj b/examples/vim.clj new file mode 100755 index 00000000..702a1739 --- /dev/null +++ b/examples/vim.clj @@ -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)