News for hackers. Stuff that matters.
Re:Ripgrep 11 Released by SanchoPanda on Tuesday April 16, 2019 @02:15PM (#19675934)
The -pre flag is rarely mentioned but was a revelation for me in for dealing with MS office files and pdf documents. I use it every single day.

alias rgpre='rg -i --max-columns=1500 --pre rgpre'

*edit Adding my script here, and would be grateful for any improvements. Goal was to catch doc,docx,ppt,pptx,xls,xlsx, epub, mobi, and pdf and still work on termux with default packages there only.

https://gist.github.com/ColonolBuendia/314826e37ec35c616d705...

Re:Ripgrep 11 Released by burntsushi on Tuesday April 16, 2019 @02:40PM (#19676144)
That's a lovely script. And yeah, I should try to publicize --pre a bit more, since it is pretty handy. I don't use it a ton myself, but when it works, I'm really thankful for it. (That might sound weird since it's in my tool, but I was initially kind of opposed to adding it.)

One bummer is that it can slow ripgrep down quite a bit: one process per file is not good. As a tip, if you add

    --pre-glob '*.{pdf,xlsx,docx,doc,pptx,...}'
and whatever else you need, then ripgrep will only invoke an extra process for those files specifically, which can significantly speed up ripgrep if you're searching a mixed directory (or just want to have `--pre` on by default).
Re:Ripgrep 11 Released by SanchoPanda on Tuesday April 16, 2019 @03:41PM (#19676631)
That addition was an incredible time savings in my average search, I'm very grateful.

A more prominent mention, and a sample script, would be very useful imho. Just googling for a way to do this for even just one of these file types yields inferior commercial solutions at best, often just nothing.

And while I'm not sure how to make it much faster from a search perspective, I was able to find a 40% improvement in invocation by switching from rgpre to rgg as my alais.

I ended here:

alias rgg='rg -i --pre-glob '*.{pdf,xlsx,xls,docx,doc,pptx,ppt,html,epub,mobi}' --pre rgpre'

Re:Ripgrep 11 Released by burntsushi on Tuesday April 16, 2019 @03:58PM (#19676761)
Hah nice! I'll noodle on this and figure out how to publicize it more. Your script would be very helpful as an example. Do you mind if I use it in the docs somewhere?
Re:Ripgrep 11 Released by SanchoPanda on Tuesday April 16, 2019 @04:35PM (#19677066)
Please feel free.

Even a cursory mention of the ability at the end of the readme would likely help many. With a verbatim script and verbatim command using it helping many more. I only stumbled upon this feature with enough context to really get it in the Ubuntu man pages and I don't know if I ever would have gotten to the pre-glob feature to be honest.

I do believe that technically oriented non-programmers would be the biggest winners from more exposure around it.

Re:Ripgrep 11 Released by burntsushi on Tuesday April 16, 2019 @04:43PM (#19677108)
Re:Ripgrep 11 Released by ronjouch on Friday April 19, 2019 @10:49AM (#19700067)
That's indeed a lovely script. It makes for seamless searching my trove of PDFs and ebooks. Thanks for sharing it, and thanks BurntSushi for considering including it to rg's README :) !