# ask in what path the component resides in# if no answer is provided, use default value# -e flag is for giving `cd`-code completion while answering the questiondefaultValue=src/components/
read-e-p"Where is component located? (default: $defaultValue): " location
location=${location:-$defaultValue}cd$locationread-e-p"Enter component name you want to rename: " currentName
cd$currentName# if component ends with a trailing slashif[["$currentName"== */ ]];then# remove trailing slashcurrentName=${currentName%/}fiindexFile=index.ts
componentFile=$currentName.tsx
storyFile=$currentName.stories.tsx
stylesheetFile=$currentName.module.css
stylesheetScssFile=$currentName.module.scss
if[[$currentName!=""]];thenechoecho"This will try and rename:"echo"---- folder -----"echo$currentNameechoecho"---- files -----"echo - $indexFileecho - $componentFileecho - $storyFileecho - $stylesheetFileecho - $stylesheetScssFileechoread-p"Enter new name: " newName
if[[$newName!=""]];thenechoecho"search replace in files"echosed-i"s/$currentName/$newName/g"$indexFilesed-i"s/$currentName/$newName/g"$componentFilesed-i"s/$currentName/$newName/g"$storyFilesed-i"s/$currentName/$newName/g"$stylesheetFilesed-i"s/$currentName/$newName/g"$stylesheetScssFileechoecho"rename files and folders"echomv$componentFile$newName.tsx
mv$storyFile$newName.stories.tsx
mv$stylesheetFile$newName.module.css
mv$stylesheetScssFile$newName.module.scss
cd..mv$currentName$newName/
fifi