This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-12-19
Channels
- # adventofcode (52)
- # babashka (47)
- # beginners (13)
- # clojure (36)
- # clojure-belgium (1)
- # clojure-europe (14)
- # clojure-nl (1)
- # clojure-norway (14)
- # clojurescript (2)
- # clojutre (9)
- # cursive (12)
- # datomic (3)
- # deps-new (3)
- # emacs (12)
- # fulcro (5)
- # guix (1)
- # honeysql (7)
- # introduce-yourself (1)
- # jobs (1)
- # kaocha (8)
- # lsp (5)
- # membrane (5)
- # mount (7)
- # nbb (5)
- # nrepl (2)
- # off-topic (60)
- # polylith (9)
- # reclojure (2)
- # reitit (8)
- # ring (17)
- # shadow-cljs (4)
- # spacemacs (31)
- # sql (7)
- # timbre (3)
- # xtdb (15)
@cfleming did you ever get around to implement the support for matcher combinators? https://github.com/nubank/matcher-combinators/issues/31#issuecomment-1165997443
I actually have this half done in a branch, and it鈥檚 still slated for the next release.
My workflow includes frequently printing a SQL string to the REPL and then copying the string to the clipboard so I can paste it into a db tool. I鈥檇 like to automate copying the string to the clipboard. Is there some intellij scripting magic for this?
googling for clojure string clipboard gave me https://gist.github.com/brake/c944229350e91f295a1762d3274393ef
Your google fu is more powerful than mine 馃檪
Thanks!
I think it would probably be easier to go straight to the clipboard from clojure than get intellij involved
I had assumed that intellij had to be involved but your solution is better
makes sense
https://github.com/AvisoNovate/pretty has io.aviso.clipboard/{copy,paste}
, which uses the same approach as the mentioned gist.
in that past at least, that approach had the side-effect of opening a window-less app on macOS and it also took quite some time to initialize the graphical subsystem in java, before u could talk to the clipboard.
so u might want to just shell out instead and use pbcopy
/ pbpaste
on macOS, for example.
it's not very cross platform of course...
(defn pbpaste [] (-> "pbpaste" direnv/stdout-of))
where direnv/stdout-of
is defined as
(ns ginoco.direnv
(:require
[clojure.java.shell :as shell]
[clojure.string :as str]))
(defn env+
"Merge extra env vars into the specified or current process environment."
([extra-env]
(env+ (System/getenv) extra-env))
([current-env extra-env]
(reduce into {} [current-env extra-env])))
(def muted-direnv {"DIRENV_LOG_FORMAT" ""})
(comment
(env+ muted-direnv))
(defn stdout-of
"Returns the standard output of the specified command line, also trimming the
last newline from it.
If the standard error is not empty, then throws an exception with it as
the exception message."
[& args]
(let [{:keys [out err exit] :as res} (apply shell/sh args)]
;(prn res)
(if (zero? exit)
(if (string? out)
(str/trim-newline out)
out)
(-> (str (vec args) " exited with status: " exit "\n" out err)
(ex-info res)
throw))))
(comment
(stdout-of "echo" "blah")
(stdout-of "/usr/bin/false")
)
(defn exec
"Eg:
(direnv/exec \"firefox\" \"--profile\" \"test\")
which translates to:
DIRENV_LOG_FORMAT='' direnv exec . firefox --profile test"
[& args]
(shell/with-sh-env
(env+ muted-direnv)
(apply stdout-of "direnv" "exec" "." args)))
(defn which [prg] (exec "which" prg))
(comment
(exec "bash" "-c" "type $SHELL")
(which "clojure")
)