pbcopy and pbpaste are handy, for a version that works over ssh connections there is osc: https://github.com/theimpostor/osc
replies(4):
if [[ "$(uname)" == "Darwin" ]]; then
clip() {
[ -t 0 ] && pbpaste || pbcopy
}
else # assume linux if not macos
clip() {
[ -t 0 ] && xclip -o -selection clipboard || xclip -selection clipboard
}
fi
$ pbpaste | jq | pbcopy
Then I can paste it into whatever text editor I want and it's all nice & pretty-printed for me.
Bonus is that I don't have to change the command at all, just copy the minimized JSON to the clipboard (say from DBeaver, for example), then hit the 'up' arrow and enter.
[1]: https://github.com/DvdGiessen/dotfiles/blob/2c02332b4a657690... [2]: https://github.com/DvdGiessen/dotfiles/blob/2c02332b4a657690...