-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
1 changed file
with
29 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,32 @@ | ||
# Rep Grep | ||
|
||
wgrep/write-grep CLI | ||
`rep` is a command-line utility that takes [`grep`](https://en.wikipedia.org/wiki/Grep)-formatted lines via standard input, and performs a find-and-replace on them. By default, it outputs a [`diff`](https://en.wikipedia.org/wiki/Diff)-preview of the changes to standard output, and can write the changes to the in place with a flag. | ||
|
||
[![Find & replace with `rep`](rep.gif)](https://www.youtube.com/embed/QIOKKTnC9-I) | ||
|
||
## Example | ||
|
||
Output a diff to standard output replacing `foo` with `bar`: | ||
|
||
``` | ||
grep -n foo *` | rep foo bar | ||
``` | ||
|
||
Write the changes to the files in place: | ||
|
||
``` | ||
grep -n foo *` | rep foo bar -w | ||
``` | ||
|
||
The `-n` (`--line-number`) option is required so that `grep` outputs the line number for each match. | ||
|
||
## Help | ||
|
||
`grep --help` (or `grep -h`) will list help for all the command-line flags. | ||
|
||
## Acknowledgements | ||
|
||
- The idea for `rep` was inspired by [`wgrep`](https://github.com/mhayashi1120/Emacs-wgrep) for Emacs, which allows editing of a `grep` results in a buffer, and writing those changes to the source files. | ||
- The structure of the source code, and much of the functionality, was borrowed from [`sd`](https://github.com/chmln/sd), `rep` began as a fork of `sd`. | ||
- The code for specifying a custom pager for both `rep` and `ren` came from the source code for [delta`](https://github.com/dandavison/delta). | ||
|
||
[![Find & replace with `rep`](rep.gif)](https://www.youtube.com/embed/QIOKKTnC9-I) |