-
Notifications
You must be signed in to change notification settings - Fork 18
/
RenameProject.sh
executable file
·73 lines (56 loc) · 1.81 KB
/
RenameProject.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/bin/bash
#Script inspiré de https://stackoverflow.com/a/48004237/4894980
#ACK needs to be installed on the machine (brew install rename ack)
if ! hash ack 2>/dev/null; then
read -p "Ack and Rename program are not installed, do you want me to install it for you ? (y/n) " -n 1 -r
echo #new line
if [ "$REPLY" != "${REPLY#[Yy]}" ] ;then
brew install rename ack
else
echo "Ack and Rename are required, aborting."
exit 0
fi
fi
#Program
read -p "Do you really want to rename your project $1 to $2 ? (y/n) " -n 1 -r
echo #new line
if [ "$REPLY" != "${REPLY#[Yy]}" ] ;then
echo "Renaming $1 project to $2..."
find . -name "$1*" -print0 | xargs -0 rename --subst-all "$1" "$2"
find . -name "$1*" -print0 | xargs -0 rename --subst-all "$1" "$2"
echo "Following output should be empty :"
find . -name "$1*" #this output should be empty
echo "-----End of output-----"
ack --literal --files-with-matches "$1" --print0 | xargs -0 sed -i '' "s/$1/$2/g"
echo "Following output should be empty :"
ack --literal "$1"
echo "-----End of output-----"
echo -e "Next steps :
- Run pod install
- Remove .git folder
- Enable Git through Xcode
- Open your fresh new $2.xcworkspace and you are done!"
read -p "Do you want me to delete .git folder for you ? (y/n) " -n 1 -r
echo #new line
if [ "$REPLY" != "${REPLY#[Yy]}" ] ;then
rm -rf .git
fi
read -p "Do you want to edit Podfile ? (y/n) " -n 1 -r
echo #new line
if [ "$REPLY" != "${REPLY#[Yy]}" ] ;then
nano Podfile
fi
read -p "Do you want me to run pod install for you ? (y/n) " -n 1 -r
echo #new line
if [ "$REPLY" != "${REPLY#[Yy]}" ] ;then
pod install
read -p "Do you want me to open $2.xcworkspace ? (y/n) " -n 1 -r
echo #new line
if [ "$REPLY" != "${REPLY#[Yy]}" ] ;then
open $2.xcworkspace
fi
fi
else
echo "Cancel renaming."
exit 0
fi