(no title)
hoshsadiq | 4 years ago
It is essentially similar to jqplay but local.
I didn't use jid/jiq because jid uses go-simplejson, which is nowhere near as powerful as jq, and jiq seemed very buggy when I used it and it felt like it was hacked together. Plus there was no where to change jq's arguments while running it.
I'm sure this function can be improved on, but this has been good enough for me so far.
Also, I run gojq[2] instead of jq. It is a drop-in replacement for jq but is written in Go, and has some improvements over jq such as bug fixes, support for yaml input, and it also provides more helpful error messages.
[0] https://github.com/hoshsadiq/dot_files/blob/master/zshrc.d/m...
fisxoj|4 years ago
[0]: https://github.com/200ok-ch/counsel-jq
forty|4 years ago
psacawa|4 years ago
Dependencies: tmux, nodemon, less, jq, vim
[1]: https://gist.github.com/psacawa/e63c4e25a8b0405309d3a03b6b50...
[2]: https://streamable.com/jwdrqu
kbd|4 years ago
https://github.com/kbd/setup/blob/master/HOME/bin/fzr
It's just an fzf wrapper that sets up temporary files and so on. It works really well; it's amazing all the things one can use fzf for.
ossusermivami|4 years ago
alerighi|4 years ago
It's the classical tool, like sed, like awk, like a ton of unix utility that at first they seem to you easy to use, then you have to do something complex and you start abusing them, by piping things multiple times into jq, and you end up writing things like this:
I stopped using jq after realizing that I was wasting my time by trying to fix a script that used jq and didn't managed quoting correctly, trying to use different kind of quotes, even filtering the input before passing it to jq with tr replacing things. It's just another tool prone to abuse like sed, awk, tr, cut or similar things.I thought why I'm wasting my time on a tool that has a complex and limited DSL when I can write a clean python script in 10 minutes to do the same things that is easier to write, to read and most importantly to maintain.
To me a script that has to manipulate JSON should be written in an high level programming language like Python, and not be abused with tool as jq and stuff. Even I there is an already existent big bash script that you don't want to rewrite and you have to do some json processing in it... you can write an inline python script like this:
Also jq is another dependency to a script that must be installed.ris|4 years ago
If you actually "get into" jq you find out that it's a significantly neater language than it appears on the surface. Firstly it does allow you write multi-line scripts, and things start to look a lot neater once you do. Secondly it's actually a real, working, functional programming language, which allows very succinct expression of ideas which, in python, would likely require the reader to track state across explicit loops and the like.
Once you dig into the manual, you also tend to discover that a lot of the things that cause you to string multiple jq invocations together aren't actually necessary because there are quite sensible ways of handling them in-language.
It's quite laughable though to tout python over jq because of it adding a dependency. Perhaps if you're already embedded in python-land and all your environments already have python - but many (most?) of us are increasingly targeting extremely minimal container image environments. In that case, adding python is a much larger and more complex dependency than jq's single 3.8MB binary.
As someone who has to read an awful lot of other peoples deployment scripts, it's also quite nice when I see jq because it loudly advertises "all I'm doing here is mangling one piece of json into another! no side effects!". I'd much rather follow the thread of execution into that than some mystery ruby script any day.
Arnavion|4 years ago
philsnow|4 years ago
I'll definitely look into some of the other mentioned solutions for this though. I settled on skim a year+ ago and haven't revisited.
asicsp|4 years ago
rodorgas|4 years ago
hoshsadiq|4 years ago
I considered forking jid/jiq and using gojq as a library, but I ended up not going down that route because of reasons that I cannot remember. I also considered using a tui or something but FZF has so much already implemented and has a lot of it right, and I didn't particularly feel like re-inventing the wheel.
rattray|4 years ago
hoshsadiq|4 years ago
alex_smart|4 years ago