Create a gist now

Instantly share code, notes, and snippets.

@johan /README.md
Last active Sep 18, 2015

git rsif

git rsif

Usage

git rsif 'REPLACE-FROM' 'REPLACE-WITH'

Background

If you use the progamming language pike, replace-string-in-file, or pike -x rsif REPLACE-FROM REPLACE-WITH <list-of-files> might be a commonly used tool in your shell arsenal.

It just occurred to me I want a "git rsif" that does this cross-git-repository, for all text files with a literal match of "REPLACE-FROM".

Thus my ~/bin/git-rsif utility was born.

Prerequisites

You need a pike binary in your path. A quick way of getting one on osx + homebrew is brew install pike.

#! /bin/sh
git grep --text -lzF "$1" | xargs -0 -- pike -x rsif "$1" "$2" "{}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment