Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 11 You must be signed in to star a gist
  • Fork 6 You must be signed in to fork a gist
  • Save krystofbe/92aed7cd03c9a631eb3c7af490525c4e to your computer and use it in GitHub Desktop.
Save krystofbe/92aed7cd03c9a631eb3c7af490525c4e to your computer and use it in GitHub Desktop.
rename a phoenix 1.3 project
#!/bin/bash
set -e
CURRENT_NAME="Zauberantrag"
CURRENT_OTP="zauberantrag"
NEW_NAME="Wunderantrag"
NEW_OTP="wunderantrag"
ack -l $CURRENT_NAME --ignore-file=is:rename_phoenix_project.sh | xargs sed -i '' -e "s/$CURRENT_NAME/$NEW_NAME/g"
ack -l $CURRENT_OTP --ignore-file=is:rename_phoenix_project.sh | xargs sed -i '' -e "s/$CURRENT_OTP/$NEW_OTP/g"
mv lib/$CURRENT_OTP lib/$NEW_OTP
mv lib/$CURRENT_OTP.ex lib/$NEW_OTP.ex
mv lib/${CURRENT_OTP}_web lib/${NEW_OTP}_web
mv lib/${CURRENT_OTP}_web.ex lib/${NEW_OTP}_web.ex
mv test/$CURRENT_OTP test/$NEW_OTP
mv test/${CURRENT_OTP}_web test/${NEW_OTP}_web
@krystofbe
Copy link
Author

Don't forget to run brew install ack on a Mac!

@ericridgeway
Copy link

How do we run this, please? I get to change the

CURRENT_NAME="Zauberantrag"
CURRENT_OTP="zauberantrag"

NEW_NAME="Wunderantrag"
NEW_OTP="wunderantrag"

stuff to the appropriate search and replace values, but where do we put the file and how do we run it?

@krystofbe
Copy link
Author

Hi @ericridgeway!
Save this file in the project directory of your phoenix project, then open up a terminal cd into the directory and type

chmod u+x rename_phoenix_project.sh 
./rename_phoenix_project.sh 

This should rename your project

@ericridgeway
Copy link

TYVM for instant reply. I can't get it to work but prob cause I'm on windows

@krystofbe
Copy link
Author

Oh yeah, sorry, this is linux and mac only.

@wbednarski
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment