2 ms·
`rg | rep` still requires repeating the pattern. 99% of the time, all I need is a simple replacement on checked-in files[1] and for that I've had `git-gsr` in m
by js2 3y ago
`rg | rep` still requires repeating the pattern. 99% of the time, all I need is a simple replacement on checked-in files[1] and for that I've had `git-gsr` in my PATH for a decade or more:
https://gist.github.com/jaysoffian/0eda35a6a41f500ba5c458f02a29865d https://gist.github.com/jaysoffian/0eda35a6a41f500ba5c458f02...
Of course this also repeats the pattern, but that's an implementation detail I let the script handle for me. A future improvement to `rep` could be for it to invoke `rg` directly in order to avoid needing to repeat the pattern, though I suppose that could be a shell script easily enough.
[1]: How often are folks doing a global search and replace on a mass of files that isn't checked-in to a repo? I've been a sys admin and programmer for 25+ years and I think I can count on one hand the times I've ever needed to do that. If I had to do it today, I'd very likely create a temporary repo first in order to have a quick way to verify the diff and restore to previous state if need be.
- nerdponx 3y agoI use "sad" for this: https://github.com/ms-jpq/sad https://github.com/ms-jpq/sad git ls-files **/*.lua | sad foo bar