Live data from Hacker News

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

blog.burntsushi.net

61–70 of 198 posts

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

#61

Earlier quoted context omitted.

Vim is almost broken for me without fzf+rg. Feels like I’m manually grinding coffee instead of using electricity.

This comment got me to get out my French press and manually grind some beans. It wasn't a meditative and calming as I remember, and the coffee tastes a little...dusty. I guess it's time for me to update my vimrc.

Aeropress is a direct upgrade from french press and uses way less coffee

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

#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 "$file" ]; then
            $EDITOR +"${linenumber}" "$file"
    fi
  }

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

#63
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…

With fzf you can add lots of files to git while skipping some if you want:

    fza = "!git ls-files -m -o --exclude-standard | fzf -m --print0 | xargs -0 git add"
With that in the [alias] section of a gitconfig file, running git fza brings up a list of modified and not yet added files, space toggles each entry and moves to the next entry.

That alias as well as fzf+fd really speed up some parts of my workflow.

Oh and shameless plug for my guide on what to include in your zsh setup on macOS: https://gist.github.com/aclarknexient/0ffcb98aa262c585c49d4b...

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

#64
post #38

What are the reasons for grep not being replaced/improved? This topic seems a bit old by now.

For the same reason the 40yo chair I currently sit in is not being replaced with Razer UltraSeat XR3000-A. It's comfortable, fits the workplace around it, and there's no reason for getting a replacement and rebuilding everything. (Partially because a Razer-like chair already stands nearby taking care of my clothes, but that's where the analogy ends.)

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

#65
post #36

I use ripgrep with the Emacs packages project.el (comes out of the box) and dumb-jump (needs to be installed). This may not be the most popular way of using rg but I have been very pleased with the overall experience. All it takes is running package-install to install the dumb-jump package and configuring the following hook: (add-hook 'xref-backend-functions #'dumb-jump-xref-activate) The Xref key sequences and comma…

Author of ripgrep here. Looking at your regex---just by inspection, I haven't tried it, so I could be wrong---but I think you can drop the --pcre2 flag. I also think you can drop the second and third \b assertion. You might need the first one though.

The example I have posted in my comment is not a command I am typing myself. The dumb-jump package generates this command for us automatically. It is possible to customize the command it generates though. Indeed while running ripgrep manually, I do not use the --pcre2 option. Thank you for developing and maintaining this excellent tool!

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

#66

One thing I wish ripgrep had is support for AND conditions.

If you don't mind using PCRE, you can do it. For example:

    rg -P '(?=.*pat1)(?=.*pat2)(?=.*pat3)'
You could create a shell function shortcut if you need to use it often. But yeah, having it as a feature of the tool itself would be nice.

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

#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.

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

#68
post #65

Earlier quoted context omitted.

Author of ripgrep here. Looking at your regex---just by inspection, I haven't tried it, so I could be wrong---but I think you can drop the --pcre2 flag. I also think you can drop the second and third \b assertion. You might need the first one though.

The example I have posted in my comment is not a command I am typing myself. The dumb-jump package generates this command for us automatically. It is possible to customize the command it generates though. Indeed while running ripgrep manually, I do not use the --pcre2 option. Thank you for developing and maintaining this excellent tool!

Oooo gotya! That makes more sense. Thanks for the clarification.

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

#69
post #38

What are the reasons for grep not being replaced/improved? This topic seems a bit old by now.

Complete guess: it works just fine for 99.9999% of users, but greater than (1-0.999999)% chance that it would break compatibility or have a bug. Anyone who would need the performance gain would know about specialized alternatives.

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

#70

Earlier quoted context omitted.

This comment got me to get out my French press and manually grind some beans. It wasn't a meditative and calming as I remember, and the coffee tastes a little...dusty. I guess it's time for me to update my vimrc.

Aeropress is a direct upgrade from french press and uses way less coffee

I hadn't heard of this before. Thanks!
Post reply on HN