This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-10-28
Channels
- # aleph (4)
- # announcements (5)
- # babashka (28)
- # babashka-sci-dev (13)
- # beginners (63)
- # calva (76)
- # cider (113)
- # clara (7)
- # clj-kondo (42)
- # cljdoc (1)
- # clojure (170)
- # clojure-europe (20)
- # clojure-nl (17)
- # clojure-norway (3)
- # clojure-spec (12)
- # clojure-sweden (1)
- # clojure-uk (6)
- # clojurescript (55)
- # clojureverse-ops (1)
- # consulting (1)
- # core-async (9)
- # cursive (16)
- # data-science (1)
- # datascript (8)
- # datomic (27)
- # emacs (14)
- # events (1)
- # fulcro (10)
- # graphql (9)
- # gratitude (1)
- # jobs (6)
- # jobs-discuss (5)
- # leiningen (10)
- # lsp (35)
- # missionary (4)
- # nextjournal (9)
- # off-topic (46)
- # pathom (15)
- # pedestal (5)
- # polylith (37)
- # portal (15)
- # re-frame (22)
- # reagent (4)
- # reitit (5)
- # reveal (18)
- # shadow-cljs (20)
- # tools-deps (7)
- # xtdb (10)
Are beginner questions welcome? I'm trying to (sh "brew install tree")
to which i get
Cannot run program "brew install tree": error=2, No such file or directory
May be bb
can't find brew
on path, idk what am i missing.@imdad.ahmed I recommend using (babashka.tasks/shell "brew install tree")
or else you'll have to split the command into chunks yourself: (sh ["brew" "install" "tree"])
that doesn't always work correctly. there is babaskha.process/tokenize
which does it more accurately
@borkdude Thanks the quick response. That worked as expected. I was able to connect to bb nrepl via my emacs setup and also verify that the function compiles etc. (Also) Thanks for the excellent documentation! Can i ask one more question: Upon cider connect to the bb nrepl, it gives a warning saying clojure version is undetermined. Is that a known issue?
@imdad.ahmed that is a known issue, it should be harmless, but feel free to report it to #cider
random hack, was wondering how to send some initialization code to application which gets started with nrepl.cmdline, something like Leiningen :init
and cooked up this based on babashka book examples 🙂 https://gist.github.com/viesti/8959327b298950cd9c9574ce46265591
Hello everyone! I have two files, in which one I defined a function and in the second one I call it, for example:
first.clj
(def some-var “123”)
second.clj
(println some-var)
When I do this: bb first.clj second.clj
in output: #'user/second
, which not that I expected 😢
How get value from first file?
I believe that bb will take the first file as the file to execute, and the second file as an argument:
first.clj
(println *command-line-args*)
$ bb first.clj second.clj
(second.clj)
in short, I believe you can currently only execute one file (by specifying it on the command line)
There's a change in master than will provide a --init
option which sort of pre-loads the init file, so you could do something like:
$ bb --init first.clj -f second.clj
123
Alternatively, you could load first.clj
from second.clj
:
second.clj:
(load-file "first.clj")
(println some-var)
$ bb second.clj
123
and of course, you could put first.clj
on your bb classpath in bb.edn
and define a namespace in it, and then require that namespace from second.clj
Thanks for your replies @U013JFLRFS8!
is there a cross platform way to copy and retrieve data to the clipboard using babashka? and not just text, but also files etc. retrieval should be capable of the many mime types that are available
FWIW I use this in java to copy EDN as a string
(do
(defn clipboard []
(.getSystemClipboard (java.awt.Toolkit/getDefaultToolkit)))
(defn clipboard-> []
(try
(.getTransferData (.getContents (clipboard) nil) (java.awt.datatransfer.DataFlavor/stringFlavor))
(catch java.lang.NullPointerException e nil)))
(defn ->clipboard
([x] (->clipboard true x))
([pretty? x]
(let [text (if (string? x)
x
(if pretty?
(with-out-str (clojure.pprint/pprint x))
(pr-str x)))
selection (java.awt.datatransfer.StringSelection. text)]
(.setContents (clipboard) selection selection))
x)))
@U050CJFRU probably not cross platform, but here's the one for macos: https://clojurians-log.clojureverse.org/babashka/2021-04-13/1618344276.143200
Good question, I don't know. Perhaps someone else here does? We could consider adding these classes to babashka so it will work like in Java, but because awt
in my opinion stands for graphical stuff, and it's considered a bit old, I haven't done this.
(-> (p/process ["cat" "something.html"])
(p/process ["pbcopy"]))
This should work for text files (for mac).thanks @UMPJRJU9E what about arbitrary files?