Last active
December 6, 2021 13:20
-
-
Save whamtet/c000da6323072aeb6957425ee05309f7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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