Created
June 8, 2016 13:45
-
-
Save jeroenvandijk/949d19e5f47cf70e3407780a09d1086d to your computer and use it in GitHub Desktop.
Finds nrepl port of repl
This file contains hidden or 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
;; 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