Skip to content

Instantly share code, notes, and snippets.

@kumekay
Forked from nerdyworm/rename.sh
Last active November 7, 2021 06:13
Show Gist options
  • Save kumekay/8f4c8c0b88152a83c989d45f1fab810a to your computer and use it in GitHub Desktop.
Save kumekay/8f4c8c0b88152a83c989d45f1fab810a to your computer and use it in GitHub Desktop.
rename a phoenix 1.3 project
#!/bin/bash
set -e
CURRENT_NAME="CurrentName"
CURRENT_OTP="current_name"
NEW_NAME="NewName"
NEW_OTP="new_name"
ack -l $CURRENT_NAME | xargs sed -i '' -e "s/$CURRENT_NAME/$NEW_NAME/g"
ack -l $CURRENT_OTP | 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
@aratakokubun
Copy link

Thank you for useful script!
And I think a little modification not to rename the script itself makes better.

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"

@krystofbe
Copy link

Updated version for tests and not renaming the script itself: https://gist.github.com/krystofbe/92aed7cd03c9a631eb3c7af490525c4e

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