Skip to content

Instantly share code, notes, and snippets.

@jeroenvandijk
Created June 8, 2016 13:45
Show Gist options
  • Save jeroenvandijk/949d19e5f47cf70e3407780a09d1086d to your computer and use it in GitHub Desktop.
Save jeroenvandijk/949d19e5f47cf70e3407780a09d1086d to your computer and use it in GitHub Desktop.
Finds nrepl port of repl
;; From https://github.com/ChrisBlom/dotfiles/blob/132db1a82d012dc495f762654b544b7c3a82d844/lein/tracetool.clj#L10
(def pid
"Get current process PID"
(memoize
(fn []
(-> (java.lang.management.ManagementFactory/getRuntimeMXBean)
(.getName)
(clojure.string/split #"@")
(first)))))
(-> (clojure.java.shell/sh "lsof" "-Pan" "-p" (pid) "-i")
:out
(clojure.string/split-lines)
second
(clojure.string/split #" ")
(butlast)
last
(clojure.string/split #":")
last)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment