nbb

2025-11-07T08:09:01.848129Z

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

borkdude 2025-11-07T08:14:37.634689Z

There’s a JS library for it in examples, forgot the name, not at kbd right now

borkdude 2025-11-07T08:15:08.315499Z

You probably need to add another backslash or so

borkdude 2025-11-07T08:40:10.945359Z

oh yes, the lib is called "chalk"

borkdude 2025-11-07T08:41:31.071469Z

$ npx nbb -e '(println "\u001b[1;31mbold-red text\u001b[0m")'
bold-red text
thanks chatGPT - clojure doesn't support \x notation

2025-11-07T08:41:32.369839Z

Uhh yeah I remember chalk, I think recently they had a security breach though?

2025-11-07T08:42:04.140569Z

Thanks! I should have posted that I got the answer from claude (it was the same) πŸ˜…

😁 1
borkdude 2025-11-07T08:43:31.551929Z

isn't that solved by now?

borkdude 2025-11-07T08:43:47.639439Z

but yeah you can just go with the claude answer :)

2025-11-07T08:45:13.016289Z

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

2025-11-07T08:45:36.299489Z

(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 anyone

πŸ’― 1
borkdude 2025-11-07T08:45:56.590629Z

nice :)

Gregory Bleiker 2025-11-07T19:53:51.479069Z

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

borkdude 2025-11-07T20:16:00.675249Z

I'm not sure why you would use this in nbb?

Gregory Bleiker 2025-11-07T21:05:40.672579Z

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.

borkdude 2025-11-07T21:22:38.285999Z

well a similar thing could be written in nbb, but it's written in JVM Clojure / babashka right now, so this requires work

borkdude 2025-11-07T21:23:12.690619Z

perhaps an LLM is willing to do the tedious translation :)

borkdude 2025-11-07T21:24:14.666759Z

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)

πŸ‘ 1
borkdude 2025-11-07T21:24:25.204369Z

this is also written in node

borkdude 2025-11-07T21:25:02.246209Z

(https://github.com/squint-cljs/squint/tree/browser-nrepl)

borkdude 2025-11-10T11:21:29.307449Z

oh excellent, thank you!

Gregory Bleiker 2025-11-09T15:51:07.488169Z

@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?

borkdude 2025-11-09T16:06:35.421829Z

do you mean two? no that's fine

borkdude 2025-11-09T16:06:51.199279Z

maybe refreshing the browser helps

Gregory Bleiker 2025-11-09T16:15:45.192209Z

doesn't help, but if I refresh and the proxy is not running, I get an error in the browser console

Chris McCormick 2025-11-10T04:14:54.310979Z

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

πŸ™ 1