-
-
Save glyph/9beafa8a7b26e5ca9f6666448fa5810d to your computer and use it in GitHub Desktop.
git grep and replace
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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