Scooter is an interactive find-and-replace terminal UI app.
Search with either a fixed string or a regular expression, enter a replacement, and interactively toggle which instances you want to replace. You can also specify a regex pattern for the file paths you want to search.
If the instance you're attempting to replace has changed since the search was performed, e.g. if you've switched branches and that line no longer exists, that particular replacement won't occur: you'll see all such cases at the end.
Scooter respects both .gitignore
and .ignore
files. By default hidden files (such as those starting with a .
) are ignored, but can be included with the --hidden
flag.
You can add capture groups to the search regex and use them in the replacement string: for instance, if you use (\d) - (\w+)
for the search text and ($2) "$1"
as the replacement, then 9 - foo
would be replaced with (foo) "9"
.
Run
scooter
in a terminal to launch Scooter. By default the current directory is used to search and replace in, but you can pass in a directory as the first argument to override this behaviour:
scooter ../foo/bar`
A set of keymappings will be shown at the bottom of the window: these vary slightly depending on the screen you're on.
When on the search screen the following fields are available:
- Search text: Text to search with. Defaults to regex, unless "Fixed strings" is enabled, in which case this reverts to case-sensitive string search.
- Replace text: Text to replace the search text with. If searching with regex, this can include capture groups.
- Fixed strings: If enabled, search with plain case-sensitive strings. If disabled, search with regex.
- Path pattern (regex): Regex pattern that file paths must match. The relative path of the file is matched against: for instance, if searching in
/foo/
, if the path pattern is set tobar
then/foo/bar.txt
and/foo/bar/file.rs
will be included. In the same example, if the path pattern is set tofoo
then/foo/bar.txt
will not be included, but/foo/foo.txt
will be.
Ensure you have cargo installed (see here), then run:
cargo install scooter
Scooter is available as scooter
in nixpkgs, currently on the unstable channel.
You can download binaries from the releases page. After downloading, unzip the binary and move it to a directory in your PATH
.
- Linux
- Intel/AMD:
*-x86_64-unknown-linux-musl.tar.gz
- ARM64:
*-aarch64-unknown-linux-musl.tar.gz
- Intel/AMD:
- macOS
- Apple silicon:
*-aarch64-apple-darwin.tar.gz
- Intel:
*-x86_64-apple-darwin.tar.gz
- Apple silicon:
- Windows
*-x86_64-pc-windows-msvc.zip
Ensure you have cargo installed (see here), then run the following commands:
git clone [email protected]:thomasschafer/scooter.git
cd scooter
cargo install --path . --locked
Contributions are very welcome! I'd be especially grateful for any contributions to add Scooter to popular package managers. If you'd like to add a new feature, please create an issue first so we can discuss the idea, then create a PR with your changes.