Skip to content

Instantly share code, notes, and snippets.

@jamesmfriedman
Last active May 19, 2020 17:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamesmfriedman/cc8ef976888962b3d9a0d252cf7ec2d0 to your computer and use it in GitHub Desktop.
Save jamesmfriedman/cc8ef976888962b3d9a0d252cf7ec2d0 to your computer and use it in GitHub Desktop.
Rename all camelcase files to kebab case, and all ts to tsx because OS is case insensitive love React.
rm -rf temp \
&& mkdir temp \
&& git mv src/* temp \
&& find ./temp -name '*' -type f -exec sh -c "echo '{}' \
| sed 's/\([a-z]\)\([A-Z]\)/\1-\2/g'\
| sed 's/\([A-Z]\{2,\}\)\([A-Z]\)/\1-\2/g' \
| sed 's/\.ts$/\.tsx/g' \
| sed 's/\.\/temp/\.\/src/g' \
| tr '[:upper:]' '[:lower:]' \
| xargs -I newName sh -c 'dirname newName | xargs mkdir -p && git mv --force {} newName'
" \; \
&& rm -rf temp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment