/usr/local/bin/js-beautify -rd <the filename>
On 7 Apr 2020, at 8:59, jh wrote:
I realise it would only work if the document is saved to disk of course. js-beautify has the option to read from STDIN as well, so can I do that, and have the output piped back in to the current document?
Yep, do it with STDIN/STDOUT. Here is a text filter I've got installed:
#!/bin/sh
## https://github.com/einars/js-beautify
## https://www.npmjs.org/package/js-beautify
# js-beautify -f - --good-stuff
/usr/local/bin/js-beautify --e4x -f -
Using STDIN/STDOUT means you also process the selected text, rather than processing the whole file.
-cng
--
Charlie Garrison <cha...@garrison.com.au>
Garrison Computer Services <http://www.garrison.com.au>
PO Box 380
Tumbarumba NSW 2653 Australia
On 7 Apr 2020, at 10:45, jh wrote:
It's working perfectly.
That's great. I've stopped using that one in favour of a custom prettifier that looks at document language and fires off different tool (JSON/Javascript/Perl/SQL/etc), but the concept is still the same. I was getting tired of different key shortcuts depending on language; now all prettifiers are cmd-ctrl-P. Easy. :-)
In my frantic googling I also found this:
https://gist.github.com/brentsimmons/7819109
but it requires node. Yours is way more elegant.
Using a node module/wrapper is perfectly good solution too, but certainly not as elegant and requires more setup/installation.