Skip to content

Instantly share code, notes, and snippets.

@glyph
Forked from christilden/.profile fragment
Last active January 19, 2023 00:53
Show Gist options
  • Save glyph/9beafa8a7b26e5ca9f6666448fa5810d to your computer and use it in GitHub Desktop.
Save glyph/9beafa8a7b26e5ca9f6666448fa5810d to your computer and use it in GitHub Desktop.
git grep and replace
gg_replace() {
if [[ "$#" -lt "2" ]]; then
echo "
Usage:
$0 term replacement file_mask
Example:
$0 cappuchino cappuccino '*.html'
";
else
local find="$1"; shift;
local replace="$1"; shift;
git grep -zlI "${find}" -- "$@" |
xargs -0 sed -e "s/${find}/${replace}/g" -i '' ;
fi;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment