7 ms·
Let me drop a link to my jq zsh plug-in: https://github.com/reegnz/jq-zsh-plugin https://github.com/reegnz/jq-zsh-plugin I find the biggest problem with jq is
by reegnz 3y ago
Let me drop a link to my jq zsh plug-in:
https://github.com/reegnz/jq-zsh-plugin https://github.com/reegnz/jq-zsh-plugin
I find the biggest problem with jq is that the feedback loop is not tight enough. With this jq-repl the expression is evaluated at every keystroke.
- neuromanser 3y agohttps://github.com/reegnz/jq-zsh-plugin/blob/e61804e35a593ada9c4d23ee5c957d08974ac382/jq.plugin.zsh#L17 https://github.com/reegnz/jq-zsh-plugin/blob/e61804e35a593ad... zshbuiltins(1): Unlike parameter assignment statements, typeset's exit status on an assignemt that involves a command substitution does not reflect the exit status of the command substitution. Therefore, to test for an error in a command substitution, separate the declaration of the parameter from its initialization.
- reegnz 3y agoFixed: https://github.com/reegnz/jq-zsh-plugin/pull/25 https://github.com/reegnz/jq-zsh-plugin/pull/25
- seanp2k2 3y agoNice, esp reading Calzifier’s comment above and remembering how many times I’ve cursed the JQ syntax because of quoting issues…another “trick” I’ve been using is for any non-trivial JQ filter, stick it in a file or at least a heredoc and feed it to JQ using -f for much less quote-escaping malarkey.
- bazzargh 3y agonice, but... I'd written something like this (as a program you pipe to, not autocomplete) before, but when there's an error, I try to show the error then the last-good-output. The reason for this is that when you're typing a complex command you want to have the json visible to guide your thinking, just displaying the error hides it. The way I did this was to store both the last working query and the last working output, I'd only reuse it if the last working query was a prefix of the current query - that avoids the awkward case where you are deleting letters from the output, so you need an output further back in history (which I didn't store, wasn't worth the hassle) Feature request?
- ykonstant 3y agoNice plugin; I got it and will be using it. Browsing the code, I saw a couple of small errors; not too serious, but some error handling is incorrect. In your `jq_complete()` function, for instance, you have local query="$(__get_query)" local ret=$? Unless the `local` assignment to `query` fails, `ret` will always be 0 regardless of the return value of `__get_query`. To fix this, you would need your first line to be local query; query="$(__get_query)" and so on.
- neuromanser 3y agoI pointed out exactly this in https://news.ycombinator.com/item?id=38188500 https://news.ycombinator.com/item?id=38188500
- reegnz 3y agoFixed: https://github.com/reegnz/jq-zsh-plugin/pull/25 https://github.com/reegnz/jq-zsh-plugin/pull/25
- rustyminnow 3y agoNice! Let me piggyback to mention the (neo)vim plugin I use for tightening the loop... https://github.com/phelipetls/vim-jqplay https://github.com/phelipetls/vim-jqplay It's great for building large complex queries that will eventually live in scripts, but your zsh plugin seems to hit a real sweet spot of fast feedback for ad-hoc queries too! Huge props!
- reegnz 3y agoYeah, I tend to use that one as well, but for me it just feels 'right' as a line editor plugin. I'm running a lot of kubectl commands and for me this plugin proved to be invaluable.