Apply the pie, on the fly
This file contains hidden or 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
| #!/usr/bin/env bash | |
| # | |
| # https://gist.github.com/jeebak/f9088cede18d31f2d3a0 | |
| # | |
| # Added to: https://github.com/unixorn/git-extra-commands | |
| # Further updates will be there. | |
| # | |
| [[ $# -ne 2 ]] && echo "Usage: git pie-ify pattern replacement" 1>&2 && exit 1 | |
| pattern="$(sed 's;/;\\/;g' <<< "$1")" | |
| replacement="$(sed 's;/;\\/;g' <<< "$2")" | |
| while read -r file; do | |
| if [[ -f "$file" ]]; then | |
| echo "Processing: '$file'" | |
| # TODO: fall back to sed, if perl's not available, accounting for different | |
| # (osx/linux) versions. | |
| perl -p -i -e 's/'"$pattern"'/'"$replacement"'/g' "$file" | |
| fi | |
| done <<< "$(git grep --name-only "$pattern")" |