Created
March 20, 2018 12:59
-
-
Save vvvvalvalval/090603f8e366beead774cf216d2a4aa8 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
(defn pprint-to-clipboard | |
"Copies a pretty-printed representation of value `v` to the clipboard. | |
When `v` is not supplied, copies the last REPL output (*1). | |
Useful for copying and pasting REPL output to an editor buffer." | |
([] | |
(pprint-to-clipboard *1)) | |
([v] | |
(-> (java.awt.Toolkit/getDefaultToolkit) | |
.getSystemClipboard | |
(.setContents | |
(java.awt.datatransfer.StringSelection. | |
(with-out-str | |
(clojure.pprint/pprint v))) | |
nil)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment