5 ms·
Author here. Thanks for sharing! Have you seen gron[1]? It can't do everything that jq can, but it is much more in the unix philosophy than jq. It simply flatt
by agbell 5y ago
Author here. Thanks for sharing!
Have you seen gron[1]? It can't do everything that jq can, but it is much more in the unix philosophy than jq. It simply flattens and unflattens json out into lines so you can use standard unix tools on it.
▶ gron
"https://api.github.com/repos/tomnomnom/gron/commits?per_page=1" | fgrep "commit.author"
json[0].commit.author = {};
json[0].commit.author.date = "2016-07-02T10:51:21Z";
json[0].commit.author.email = "mail@tomnomnom.com";
json[0].commit.author.name = "Tom Hudson";
▶ gron "https://api.github.com/repos/tomnomnom/gron/commits?
per_page=1" | fgrep "commit.author" | gron --ungron
[
{
"commit": {
"author": {
"date": "2016-07-02T10:51:21Z",
"email": "mail@tomnomnom.com",
"name": "Tom Hudson"
}
}
}
]
[1] https://github.com/tomnomnom/gron https://github.com/tomnomnom/gron
- bloopernova 5y agoalso, have you seen this fzf "trick"? I am sorry for spamming this comment, but I wanted to share it with all the fzf users because I found it so game-changing: I use "ESC-c" a lot. It calls fzf and fd, you type a part of your directory name, hit enter, and it cd's to that directory. export FZF_ALT_C_COMMAND='fd --type directory' That's in my .zshenv. It's incredibly useful if you have multi-layered project directories. Like ~/Projects/Terraform/Cool_Project - you'd hit esc-c, type cool, hit enter and you're in the place you wanted to be.
- agbell 5y agoVery cool! I use zoxide as a alias for cd to do this. But it only really works if you have cded using the full path in the past. But usually I have.
- lobocinza 5y agoI use a similar trick but with aliases. If I want to cd to let's say "~/work/john/some-project" I just type 'fcd' on the console and then "w j s" and "ENTER". Most of the times it work as expected and is really fast. This is a mode provided by a helper that I wrote for fzf to make it easier to use and more useful. In essence it's just a shell script with a bunch of fzf tricks pre-configured. https://github.com/danisztls/fzfx/ https://github.com/danisztls/fzfx/
- bloopernova 5y agoThat looks really useful, thank you. Plus when you use it, you can chant "GRON. GRON" like you're an Orc about to attack Minas Tirith!
- coldacid 5y agoI definitely know about gron. I maintain the Chocolatey package[1] for it for all us Windows slobs. [1] https://community.chocolatey.org/packages/gron https://community.chocolatey.org/packages/gron
- ctrlp 5y ago`gron` is super useful for sed/awk manipulation of json data rather than writing a complicated `jq` script. Both are great, though.
- gryn 5y agoI personally have settled for fx[1], there's no need to learn yet another tool's syntax, specificities, and quirks. js anonymous functions are valid inputs to the tool. when the transformation turns to be more complex than expected I can just copy and paste what I've made so far into a nodejs script. you can also configure a .fxrc file to automatically import npm packages that you might find useful, shortcuts, or your personal functions. [1] https://github.com/antonmedv/fx https://github.com/antonmedv/fx
- deleted 5y ago[deleted]
- dmos62 5y agoIt seems so obvious now that someone's done it. Doing things in a Unix-y way often requires imagination; this is a great example of that.