Skip to content

Commit deff0c1

Browse files
committed
Merge pull request #2 from jeebak/pie-fiy
Add git-pie-ify
2 parents 00f2cb1 + f339e2c commit deff0c1

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ git clone this repository, then add it to your `$PATH`. Nothing here actually re
111111
* git-nuke - Zach Holman's [dotfiles](https://github.com/holman/dotfiles)
112112
* git-object-deflate - Ryan Tomayko's [dotfiles](https://github.com/rtomayko/dotfiles)
113113
* git-outgoing - Michael Markert's [dotfiles](https://github.com/cofi/dotfiles)
114+
* git-pie-ify - JeeBak Kim's [gist](https://gist.github.com/jeebak/f9088cede18d31f2d3a0)
114115
* git-promote - Trevor's [Improving My git Workflow](http://hoth.entp.com/2008/11/10/improving-my-git-workflow) blog post
115116
* git-prune-branches - Michael Demmer in [jut-io/git-scripts](https://github.com/jut-io/git-scripts/blob/master/bin/git-prune-branches)
116117
* git-publish - Michael Markert's [dotfiles](https://github.com/cofi/dotfiles)

git-pie-ify

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env bash
2+
#
3+
# https://gist.github.com/jeebak/f9088cede18d31f2d3a0
4+
#
5+
6+
[[ $# -ne 2 ]] && echo "Usage: git pie-ify pattern replacement" 1>&2 && exit 1
7+
8+
pattern="$(sed 's;/;\\/;g' <<< "$1")"
9+
replacement="$(sed 's;/;\\/;g' <<< "$2")"
10+
11+
while read -r file; do
12+
if [[ -f "$file" ]]; then
13+
echo "Processing: '$file'"
14+
# TODO: fall back to sed, if perl's not available, accounting for different
15+
# (osx/linux) versions.
16+
perl -p -i -e 's/'"$pattern"'/'"$replacement"'/g' "$file"
17+
fi
18+
done <<< "$(git grep --name-only "$pattern")"

0 commit comments

Comments
 (0)