5 releases

0.2.1 Nov 30, 2024
0.2.0 Nov 30, 2024
0.1.2 Nov 17, 2024
0.1.1 Nov 14, 2024
0.1.0 Nov 13, 2024

#2283 in Command line utilities

Download history 344/week @ 2024-11-11 132/week @ 2024-11-18 154/week @ 2024-11-25 143/week @ 2024-12-02 206/week @ 2024-12-09

703 downloads per month

MIT license

1.5MB
2K SLoC

scooter

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 preview

Features

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".

Usage

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.

Search fields

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 to bar then /foo/bar.txt and /foo/bar/file.rs will be included. In the same example, if the path pattern is set to foo then /foo/bar.txt will not be included, but /foo/foo.txt will be.

Installation

Cargo

Ensure you have cargo installed (see here), then run:

cargo install scooter

Homebrew

On macOS and Linux, you can install Scooter using Homebrew:

brew install scooter

NixOS

Scooter is available as scooter in nixpkgs, currently on the unstable channel.

Prebuilt binaries

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
  • macOS
    • Apple silicon: *-aarch64-apple-darwin.tar.gz
    • Intel: *-x86_64-apple-darwin.tar.gz
  • Windows
    • *-x86_64-pc-windows-msvc.zip

Building from source

Ensure you have cargo installed (see here), then run the following commands:

git clone git@github.com:thomasschafer/scooter.git
cd scooter
cargo install --path . --locked

Contributing

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.

Dependencies

~13–24MB
~336K SLoC