by subset on 11/30/23, 10:21 AM with 188 comments
by stinos on 11/30/23, 11:13 AM
function frg {
$result = rg --ignore-case --color=always --line-number --no-heading @Args |
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'
if ($result) {
& ($env:EDITOR).Trim("`"'") $result.Split(': ')[0]
}
}
There are other ways to approach this, but for me this is a very fast way of nailing down 'I now something exists in this multi-repo project but don't know where exactly nor the exact name'edit this comes out of https://github.com/junegunn/fzf/blob/master/ADVANCED.md and even though you might not want to use most of what is in there, it's still worth glancing over it to get ideas of what you could do with it
by susam on 11/30/23, 12:56 PM
(add-hook 'xref-backend-functions #'dumb-jump-xref-activate)
The Xref key sequences and commands work fine with it. If I type M-. (or C-u M-.) to find definitions of an identifier in a Python project, dumb-jump runs a command like the following, processes the results, and displays the results in an Xref buffer. rg --color never --no-heading --line-number -U --pcre2 --type py '\s*\bfoo\s*=[^=\n]+|def\s*foo\b\s*\(|class\s*foo\b\s*\(?' /path/to/git/project/
The above command shows how dumb-jump automatically restricts the search to the current file type within the current project directory. If no project directory is found, it defaults to the home directory.By the way, dumb-jump supports the silver searcher tool ag too which happens to be quite fast as well. If neither ag nor rg is found, it defaults to grep which as one would expect can be quite slow while searching the whole home directory.
by MrHamdulay on 11/30/23, 12:12 PM
by xezian on 11/30/23, 2:43 PM
Random other helpful flag I use often is -M if any of the matches are way too long to read through and cause a lot of terminal chaos. Just add `-M 1000` or adjust the number for your needs and the really long matches will omit the text context in the results.
by PaulDavisThe1st on 11/30/23, 2:32 PM
I use ag (typically from inside Emacs) on a 900k LOC codebase and it is effectively instantaneous (on a 16 core Ryzen Threadripper 2950X). I just don't have a need to go from less than 1 second to "a bit less than less than 1 second".
Speed is not the defining attribute of the "new greps" - they need to be assessed and compared in other ways.
by latexr on 11/30/23, 10:41 AM
by larodi on 11/30/23, 12:19 PM
this above all true UNLESS you need multi-line matches with UTF8, where ripgrep is not so fast, because it needs to fall back to the other PCRE2 lib
by jedisct1 on 11/30/23, 11:38 AM
The optional Google search syntax also very convenient.
by mariopt on 11/30/23, 1:02 PM
by entropie on 11/30/23, 2:50 PM
by ashton314 on 11/30/23, 9:10 PM
[1]: https://github.com/minad/consult#grep-and-find [2]: https://lambdaland.org/posts/2023-05-31_warp_factor_refactor...
by bawolff on 11/30/23, 3:25 PM
by nikbackm on 11/30/23, 12:52 PM
by jmarchello on 11/30/23, 12:41 PM
by abnry on 11/30/23, 2:02 PM
by devnine on 11/30/23, 3:22 PM
by gquere on 11/30/23, 2:57 PM
by stabbles on 11/30/23, 11:15 AM
by zinodaur on 11/30/23, 7:11 PM
by Night_Thastus on 11/30/23, 3:52 PM
For those just using it to search through a codebase, don't forget -F for string literals.
by pie_flavor on 11/30/23, 10:28 PM
by shmerl on 11/30/23, 8:02 PM
by bhasi on 11/30/23, 4:44 PM
by bluedays on 11/30/23, 12:34 PM
by zoobab on 11/30/23, 11:18 AM