RipGrep’s Annoying Message

Ripgrep Annoying Message

The Grep command is part of the UNIX toolkit. Every UNIX/Linux user has used the grep command at some point. It’s a powerful tool. But there are some downsides to dealing with grep input, processing and output. So the Ripgrep command was to address these issues. Ripgrep is part of the modern UNIX suite of commands that respects your gitignore files, provides better option switches, improves the display output. RipGrep is an amazing tool. But lately I’ve been having an issue.

The Problem

I like that RipGrep will color the matching string in the output. But I’ve been experiencing a problem where I get truncated output with something that ends like [... 1 more matches] which feels kinda annoying. It gives the feeling that I’m missing something. The bigger part of what annoyed me is that I didn’t understand why it was happening. What is causing this? How can I make this not happen? After some experimentation, I figured out the reason.

The Solution

This truncated output is the result of two options: --max-columns and --max-columns-preview. Now that I understand how they work, I can see the value in using them. The --max-columns takes an integer that represents the maximum length of the matching line. So let’s say you’ve set it to 80 columns. If the term you’re searching for, is within the 80 character limit, it will be displayed in colored text. When your matching text is beyond the 80-column limit, you’ll see [Omitted long line with 1 matches]. This is meant to keep your terminal output clean. Without this, if you have a matching line that was, say 900 characters long, then that text of the matching line would wrap the output across the width of your terminal — thereby making your terminal look cluttered.

The other parameter --max-columns-preview will show the beginning of the line up to the value determined by the --max-columns option. That way, you get a better idea of the line that matched. Also, you’ll recognize it better in your editor.

One more thing. If you do specify these options in your ripgreprc config file, you can temporarily disable the effect by specifying --max-columns=0 on the command line. The value of zero in this instance is like saying “unlimited” length.

So I hope this helps solve your frustration if you find that Ripgrep is truncating your output and you’re not certain why. Happy computing!

Share Your Thoughts

I'd love to hear your thoughts on the article.