Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/robenkleene/rep-grep
https://github.com/robenkleene/rep-grep
Last synced: 22 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/robenkleene/rep-grep
- Owner: robenkleene
- License: mit
- Created: 2022-11-19T16:34:52.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-02-06T10:51:33.000Z (4 months ago)
- Last Synced: 2024-05-09T10:23:22.339Z (about 1 month ago)
- Language: Rust
- Size: 15.9 MB
- Stars: 92
- Watchers: 4
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Lists
- cli-apps - Rep - Rep is a command-line utility that takes grep-formatted lines via standard input, and performs a find-and-replace on them. (<a name="text-search-replace"></a>Text search and replace (alternatives to sed))
- awesome-cli-apps - Rep - Rep is a command-line utility that takes grep-formatted lines via standard input, and performs a find-and-replace on them. (<a name="text-search-replace"></a>Text search and replace (alternatives to sed))
README
# Rep
`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 with a flag it can write the changes to the files in place.
[![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
```Add the `-w` flag to 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.
## Installation
`rep` is available via [`cargo`](https://github.com/rust-lang/cargo):
```
cargo install rep-grep
```## Configuration
The default pager is `less`, the `REP_PAGER` environment variable can be used to override the pager (e.g., `export REP_PAGER=delta` in Bash).
## Help
`rep -h` (or `rep --help`, `--help` provides slightly longer explanations of some options) will list help for all the command-line flags.
## Acknowledgements
- `rep` was inspired by [`wgrep`](https://github.com/mhayashi1120/Emacs-wgrep) for Emacs, which allows editing `grep` results in an Emacs buffer and then writing those changes to the source files.
- Much of the functionality, and the overall structure of the source code, was borrowed [`sd`](https://github.com/chmln/sd). `rep` began as a fork of `sd`.
- The code for specifying a custom pager for `rep` was borrowed from [`delta`](https://github.com/dandavison/delta).