How would one print an ansi escape sequence to the terminal? My understanding I could do (println "\x1b[1;31mbold-red text") but it fails at the parse phase due to not recognizing that escape sequence
Thereβs a JS library for it in examples, forgot the name, not at kbd right now
You probably need to add another backslash or so
oh yes, the lib is called "chalk"
$ npx nbb -e '(println "\u001b[1;31mbold-red text\u001b[0m")'
bold-red text
thanks chatGPT - clojure doesn't support \x notationUhh yeah I remember chalk, I think recently they had a security breach though?
Thanks! I should have posted that I got the answer from claude (it was the same) π
https://semgrep.dev/blog/2025/chalk-debug-and-color-on-npm-compromised-in-new-supply-chain-attack/
isn't that solved by now?
but yeah you can just go with the claude answer :)
That's fair now that you mention it. I suppose they were compromised only for 8-ish hours and the version was deprecated... anyway curious how a more minimal implementation will work out
(ns my-project.colors
(:require
[clojure.string :as s]))
(defn color
[color strs]
(let [s (s/join " " strs)]
(str "\033[" color "m" s "\033[0m")))
(defn black
[& strs]
(color 30 strs))
(defn red
[& strs]
(color 31 strs))
(defn green
[& strs]
(color 32 strs))
(defn yellow
[& strs]
(color 33 strs))
(defn blue
[& strs]
(color 34 strs))
(defn magenta
[& strs]
(color 35 strs))
(defn cyan
[& strs]
(color 36 strs))
(defn white
[& strs]
(color 37 strs))
(defn default
[& strs]
(color 39 strs))
For reference if useful to anyonenice :)
Can I use sci.nrepl.browser-server in nbb? Or is it the same as nbb.nrepl-server? I tried to require it, but nbb can't find the namespace
I'm not sure why you would use this in nbb?
I'm running a server in nbb that serves a page running scittle. I would like to start the proxy to the page in the server process.
well a similar thing could be written in nbb, but it's written in JVM Clojure / babashka right now, so this requires work
perhaps an LLM is willing to do the tedious translation :)
perhaps I already made a start in squint btw, I'm doing a similar thing there to support nrepl in the browser (in a branch right now)
this is also written in node
oh excellent, thank you!
@borkdude I tried using bb to create the nrepl proxy (which I think succeeded). However, when connecting with clojure -T:nrepl :port 1339, there is no prompt. However, if I kill the proxy process, then rebel also quits, so there must be some kind of connection, but no eval prompt. I can also see the websocket in the browser dev tools, so the scittle part seems to be working as well. I have to sections with x-scittle, is that a problem?
do you mean two? no that's fine
maybe refreshing the browser helps
doesn't help, but if I refresh and the proxy is not running, I get an error in the browser console
I had to do this for cljs-josh - maybe you can re-use the code: https://github.com/chr15m/cljs-josh/blob/main/josh.cljs#L36-L247