This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-04-02
Channels
- # asami (5)
- # aws (16)
- # babashka (41)
- # babashka-sci-dev (44)
- # beginners (157)
- # biff (3)
- # cider (1)
- # clj-commons (1)
- # cljdoc (22)
- # clojure (7)
- # clojure-dev (5)
- # clojure-europe (13)
- # clojure-nl (1)
- # clojure-uk (1)
- # clojurescript (17)
- # core-typed (13)
- # cursive (14)
- # datascript (10)
- # events (1)
- # fulcro (2)
- # graalvm (2)
- # gratitude (1)
- # jobs (3)
- # lsp (229)
- # pathom (2)
- # pedestal (3)
- # portal (53)
- # re-frame (7)
- # remote-jobs (1)
- # spacemacs (14)
- # xtdb (6)
Hi folks. Is it possible to reproduce something like this in bb
?
#!/bin/bash
printf "%s\n%s" foo bar | fzf
fzf
[1] displays foo
and bar
in a list of options, and the user selects one option. I’d like to get the return value as well.
I tried using this but the output is not visible:
(sh "bash" "-c" "printf \"%s\n%s\" foo bar | fzf")
[1]: https://github.com/junegunn/fzfAre you trying to call fzf from within a bb script, or are you trying to pipe the output from bb into fzf?
The first option. The bb
script is supposed to be used interactively. It will fetch some data, present it to the user thru fzf
, and do stuff with the selection.
To call fzf with a string, you can call
(fzf "a\nb\nc\n")
for example and it will offer only those completionsWill you include automatically in bb?
No, the point is that it runs from source. We could have included it as a built-in ages ago, but it runs from source so we don't have to.
Hey!
Using neil
, I frequently get the latest version of a library - like org.clojure/clojure {:mvn/version "1.11.1-rc1"}
or hiccup/hiccup {:mvn/version "2.0.0-alpha2"}
- when I really wanted Clojure 1.11.0
or Hiccup 1.0.5
.
If we had a way to list out versions, we could fuzzy-search on that, and pipe the result into an "add to deps.edn" command. I gave it a shot, and got it working with Clojars. Source: https://github.com/teodorlu/neil. A bit of messy discussion in
.
Open questions:
• What about Maven and Git?
• neil add dep
vs neil dep add
? I didn't find a neat place to put neil dep versions
in the default CLI structure to put version listing. But backwards compatibility is also good.
• Separating version selection from adding a dependency is one way forward. Another way is to provide a version selection command to neil add dep
, supporting stuff like neil add dep hiccup/hiccup :select-cmd fzf
.
Not sure if this is something other people would like? Thoughts/comments?
Personally I find neil add dep :lib
too long and I've wanted to change it to something more intuitive shorter.
We could add automatic fzf support if we can find fzf on the path (using babashka.fs/which, it works cross platform)
we could try to dispatch on one of the present keywords, if :lib
is present, we assume you want to add a dep
> We could add automatic fzf support if we can find fzf on the path (using babashka.fs/which, it works cross platform) There's lots of other options for selection too, though. Rofi is one. Example:
neilz dep versions hiccup/hiccup | rofi -dmenu | xargs neilz dep add
Personally, I prefer fzf. It stays in the terminal, and is fast.We could do fzf support and if fzf is not present, you maybe get a list of options and you can type a number?
Also, personally I'm not interested in all versions back to the beginning of a library, usually the top 10 is ok for me
Now you're considering building shelling out til fzf
straight into neil add dep
?
WIth the pipe solution, neil
doesn't need to know about fzf
.
> Also, personally I'm not interested in all versions back to the beginning of a library, usually the top 10 is ok for me
Same for me, seems to be approximately what the clojars API gives in :recent_versions
We'd still need a place to fit the version listing into neil's CLI, though. What do you think about that? Assuming that we can find a solution for Git and Maven deps.
I'm for adding this. If you could start chopping this up in tiny manageable issues and after some agreement, tiny manageable PRs, would be great :)
Working on the bb script was a joy, by the way. I started a reload loop:
rg --files | entr -rc bash -c "bb gen-script && neilz addz dep :lib hiccup/hiccup"
and printed here and there to see what was happening.> I'm for adding this. If you could start chopping this up in tiny manageable issues and after some agreement, tiny manageable PRs, would be great 🙂 My schedule is somewhat unpredictable at the moment, but I'd be happy contributing what I can!
> chopping this up in tiny manageable issues Any suggestions for what kinds of issues? "CLI for listing available versions of library"? More?
Issue: CLI for listing available versions of a library https://github.com/babashka/neil/issues/16
Not sure what the %22
stuff in the maven search URLs are. Does it casuse exact matches rather than "string contains"?
https://github.com/babashka/neil/blob/65b5508a8496abe4d3a7168205b211760e9f4a8a/src/babashka/neil.clj#L25
Got it working for Maven coordinates:
$ neilz dep versions :lib org.clojure/clojure
:lib org.clojure/clojure :version 1.11.1-rc1
:lib org.clojure/clojure :version 1.11.0
:lib org.clojure/clojure :version 1.11.0-rc1
:lib org.clojure/clojure :version 1.11.0-beta1
...
I've got a feeling that version count should probably be configurable.scittle allows for quick fun with reagent ❤️ https://codepen.io/ordnungswidrig/pen/xxpPYNO (I wanted to generate such 3d effect mosaic background for some print design. Reagent and some CSS was the quickest I could think of. I could’t resist and animate it 😛 )