Home

Awesome

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:

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.

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

Editor configuration

Below are a couple of ways to configure Scooter to run in a floating window, without leaving your editor.

Helix

If you are using Helix in Tmux, you can add a keymap like the following:

[keys.select.ret]
s = ":sh tmux popup -xC -yC -w90% -h90% -E scooter"

The above uses <return-s> but this can of course be changed.

Neovim

Install Toggleterm as per the instructions here, and then add the following Lua configuration, which opens up Scooter with <leader>s:

local Terminal = require("toggleterm.terminal").Terminal

local scooter = Terminal:new({ cmd = "scooter", hidden = true })

function _scooter_toggle()
  scooter:toggle()
end

vim.keymap.set("n", "<leader>s", "<cmd>lua _scooter_toggle()<CR>", {
  noremap = true,
  silent = true,
  desc = "Toggle Scooter"
})

This can of course be tweaked to your liking.

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.