Skip to content

Instantly share code, notes, and snippets.

@whamtet
Last active December 6, 2021 13:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save whamtet/c000da6323072aeb6957425ee05309f7 to your computer and use it in GitHub Desktop.
Save whamtet/c000da6323072aeb6957425ee05309f7 to your computer and use it in GitHub Desktop.
#!/opt/homebrew/bin/planck
(require '[planck.core :refer [*in* slurp]])
(require '[planck.shell :refer [sh]])
(defn round-nth [s i]
(nth s (mod i (count s))))
(let [to-open
(as-> *in* $
(slurp $)
(.trim $)
(.split $ "\n")
(map #(-> % (.split ":") first) $))]
(if-let [index (first *command-line-args*)]
(sh "open" (round-nth to-open (js/Number index)))
(let [to-open (distinct to-open)]
(if (<= (count to-open) 100)
(doseq [path to-open]
(sh "open" path))
(println (count to-open) "files! Not opening.")))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment