To search all files in a #git repo on the commandline, you use…
@adamchainz Either use #Counsel `counsel-git-grep`, or good ol' `rgrep`.
#Emacs is a very comfortable and powerful way to navigate a code base.
But since you specified command-line @adamchainz, I guess I'd be using `grep -r | grep -v '/.git/'`.
Way too often, the thing I'm searching for turns out to be in a file that's not actually tracked by the VCS. And it's infrequently enough that I waste too much time asking why Git can't find it.
So if I'm searching the files, I'm going to use a command that searches all the files without asking Git, and just filtering explicitly.
@adamchainz grin (or better my porting to python3 https://pypi.org/project/grin3/)
@adamchainz I use ack from the root of the repo
@adamchainz I use telescope in neovim (that under the hood should use ripgrep) or vscode search
@adamchainz `git grep` for things in a repo, otherwise ripgrep for other stuff
@adamchainz if I need to find something, I use ripgrep. But if I need to run a tool (linter, formatter, etc.) on files that contain something, it's git-grep, because that are usually the ones I want to touch. Same with fd / git-ls-files
@adamchainz "code ." and then find in files. If I'm searching in a repo I'm going to want surrounding context or plan to modify, so no point sticking to the command line.
@adamchainz silver searcher (`ag`)
@adamchainz I mostly use ripgrep but sometimes git grep which I've customised to look like ripgrep: https://ricaud.me/blog/post/2017/04/Updating-my-code-search-tools
@adamchainz I mostly just cry a little then Google how to use ack again
@adamchainz from SublimeText4: ⌘+shift+f then I type in the "find:" box and I have a nice linked doc I can click on to open any relevant docs. Otherwise, I guess `git grep` works. I use `ripgrep` across ~500 folders of projects and it is super nice though.
@adamchainz I’m another one using `ag` for CLI. Also have it bound in vim with FZF.
@adamchainz often VS Code, but that's actually just ripgrep with a GUI
@adamchainz if you poke around inside the /Applications/ folder for VS Code you can actually find a working rg binary, so a lot of people have the ripgrep CLI tool installed without even knowing it's there
@webology yeah I mostly use ST search too, but when you need the CLI, rg does seem to be superior.
@adamchainz the best camera is the one that's with you. Search is like this too. Although, I am a fan of all three mentioned.
@alex @adamchainz same here
@adamchainz @alex you might say that's a sterling pun
@mike @adamchainz you can show context with grep tools
@adamchainz I don't remember why I started doing that!
Maybe I had a lot of untracked and unignored stuff in one place, or maybe because ripgrep ignores hidden dot directories by default, like .github
@hugovk I’m using it with `—hidden —glob '!.git'` which works for still searching hidden directories.
@adamchainz I'll try that out, do you have those saved in some global config or something?
@hugovk yes you can create a ripgrep config file and point to it with an env var - see end of manpage.
Writing a book section on ripgrep now with tips like this, hence the post. Would you like to beta read? If so DM me email address.
@adamchainz yes, less context switch is better for me
@adamchainz that joke should be a syn