Skip to content

Instantly share code, notes, and snippets.

@vvvvalvalval
Created March 20, 2018 12:59
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 vvvvalvalval/090603f8e366beead774cf216d2a4aa8 to your computer and use it in GitHub Desktop.
Save vvvvalvalval/090603f8e366beead774cf216d2a4aa8 to your computer and use it in GitHub Desktop.
(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