Live data from Hacker News

Ripgrep is faster than grep, ag, Git grep, ucg, pt, sift (2016)

blog.burntsushi.net

81–90 of 198 posts

Re: Ripgrep is faster than grep, ag, Git grep, ucg, pt, sift (2016)

#81
post #79

Earlier quoted context omitted.

Author of ripgrep here. Yes, qgrep uses indexing, which will always give it a leg up over other tools that don't use indexing. But of course, now you need to setup and maintain an index. The UX isn't quite as simple as "just run a search." But there isn't much of a mystery here. Someone might neglect to use qgrep for exactly the same reason that "grep is fast enough for me" might prevent someone from using ripgrep. A…

Does `build.rs` build the project? One of my favorite (Big Corp) code-bases just had a single C file (build.c) that did all the dependency tracking, like, Make, but in some nicely written (easy to understand) C code. The C file started with a shebang: a self-building-and-executing line, so we'd do this: ``` ./build.c ``` ... and then magic happened.

No. Cargo does. The `build.rs` is basically a Cargo hook that gets compiled as a Rust program and executed just before the ripgrep binary is compiled. It lets you do things like set linker flags[1] so that you can embed an XML manifest into the binary on Windows to enable "long path support."

ripgrep's build.rs used to do more, like build shell completions and the man page. But that's now part of ripgrep proper. e.g., `rg --generate man` writes roff to stdout.

[1]: https://github.com/BurntSushi/ripgrep/blob/2a4dba3fbfef944c5...

[2]: https://github.com/BurntSushi/ripgrep/blob/2a4dba3fbfef944c5...

Re: Ripgrep is faster than grep, ag, Git grep, ucg, pt, sift (2016)

#82

What's interesting is that ripgrep now also powers VS Code search with a Node.js wrapper. https://www.npmjs.com/package/@vscode/ripgrep

I've always wondered how in world search in VS Code is so fast given it's an Electron app - now I know.

Re: Ripgrep is faster than grep, ag, Git grep, ucg, pt, sift (2016)

#83

I can't think of a single time I've used grep where I thought "I wish this was faster".

Even if the answer is instant, you have a 50% performance improvement in your search just from typing "rg" instead of "grep"! From my perspective it's a no brainer. I don't HAVE a grep (because I don't have a Unix) so when I install a grep, any grep, reaching for rg is natural. It's modern and maintained. I have no scripts anywhere that might expect grep to be called "grep". Of course if you already have a grep (e.g.…

Well, a cmd script for msys64 grep in my \CmdTools is named `gr`. It feels more natural, because index-then-middle finger also does. Thinking of it, I actually hate starting anything with a middle finger (no pun). Also learning new things that do the same thing as the old one.

Re: Ripgrep is faster than grep, ag, Git grep, ucg, pt, sift (2016)

#85
post #62
post #3

It's fast indeed. And I can't help keeping promoting the combination with fzf :) For those who want to try it out, this is a Powershell function but the same principle applies in any shell. Does ripgrep then puts fuzzy searching in the resulting files+text on top while showing context in bat: function frg { $result = rg --ignore-case --color=always --line-number --no-heading @Args | fzf --ansi ` --color 'hl:-1:underl…

I wrote a bash version of this: function frg { result=`rg --ignore-case --color=always --line-number --no-heading "$@" | fzf --ansi \ --color 'hl:-1:underline,hl+:-1:underline:reverse' \ --delimiter ':' \ --preview "bat --color=always {1} --theme='Solarized (light)' --highlight-line {2}" \ --preview-window 'up,60%,border-bottom,+{2}+3/3,~3'` file="${result%%:*}" linenumber=`echo "${result}" | cut -d: -f2` if [ ! -z "…

Wow, nice, thanks! :heart:

Re: Ripgrep is faster than grep, ag, Git grep, ucg, pt, sift (2016)

#86
post #67
post #3

It's fast indeed. And I can't help keeping promoting the combination with fzf :) For those who want to try it out, this is a Powershell function but the same principle applies in any shell. Does ripgrep then puts fuzzy searching in the resulting files+text on top while showing context in bat: function frg { $result = rg --ignore-case --color=always --line-number --no-heading @Args | fzf --ansi ` --color 'hl:-1:underl…

Oh. Thanks for the tip. This might make me finally embrace powershell. I’ve been using WSL+zsh+fzf as a Windows CLI for continuity with day job Mac tools, but git CLI performance is only usable inside the WSL file system.

This might make me finally embrace powershell

Yeah, I have a bit of a love-hate relationship with it. But I actually have that with all shells out there. I don't know if it's just me or the shells, or (the most likely I think): a bit of both. But PS is available out of the box and using objects vs plain text is a major win in my book, and even though I still don't know half of the syntax by heart it feels less of an endless fight than other shells. And since I use the shell itself for rather basic things and for the rest only for tools (like shown here), we get along just fine.

Re: Ripgrep is faster than grep, ag, Git grep, ucg, pt, sift (2016)

#87
post #74
post #67

Earlier quoted context omitted.

Oh. Thanks for the tip. This might make me finally embrace powershell. I’ve been using WSL+zsh+fzf as a Windows CLI for continuity with day job Mac tools, but git CLI performance is only usable inside the WSL file system.

You can also add a small script to your WSL under `/usr/local/bin/git`: GIT_WINDOWS="/mnt/c/Program Files/Git/bin/git.exe" GIT_LINUX="/usr/bin/git" case "$(pwd -P)" in /mnt/?/*) case "$@" in # Needed to fix prompt, but it breaks things like paging, colours, etc rev-parse*) # running linux git for rev-parse seems faster, even without translating paths exec "$GIT_LINUX" "$@" ;; *) exec "$GIT_WINDOWS" -c color.ui=always…

Thank you. I will use this.

Re: Ripgrep is faster than grep, ag, Git grep, ucg, pt, sift (2016)

#88
post #60
post #30

Earlier quoted context omitted.

So I was casually searching for "ugrep vs ripgrep" articles, when I stumbled upon a couple reddit posts where apparently the authors of ugrep and ripgrep seemed to have a multi-year feud on reddit, eg. https://www.reddit.com/r/programming/comments/120wqvr/ripgre... So weird. I mean, it's just about some open source tool, right? :-/

This is so weird, even ripgrep's author is actively seeking conflict in ugrep's new release posts. Not a good colour on both of them.

How is it "seeking conflict" to correct factually wrong claims about your project?

Re: Ripgrep is faster than grep, ag, Git grep, ucg, pt, sift (2016)

#89
post #73

I messed up my conda environments once when I changed my username. So many references to the old username in the conda folders. Ripgrep saved the day!

Why not just make new ones? Regardless of whether I use Conda, Pyenv or virtualenv, I always consider the environments to be disposable.
Post reply on HN