Skip to content

Instantly share code, notes, and snippets.

@bluescreen
Last active April 24, 2025 20:32
Show Gist options
  • Save bluescreen/0fcfe2f791d0225bbd44f2f69cd16ad3 to your computer and use it in GitHub Desktop.
Save bluescreen/0fcfe2f791d0225bbd44f2f69cd16ad3 to your computer and use it in GitHub Desktop.
Refactor Typescript with preserving history and update imports
#!/bin/bash
if [ $# -ne 2 ]; then
echo "Usage: $0 <source_file_or_dir> <destination_file_or_dir>"
exit 1
fi
if ! command -v trucker &> /dev/null; then
echo "Trucker is not installed. Please run 'npm install -g trucker' first."
exit 1
fi
SOURCE=$1
DESTINATION=$2
if [ ! -e "$SOURCE" ]; then
echo "Source file or directory does not exist: $SOURCE"
exit 1
fi
if [ -e "$DESTINATION" ]; then
echo "Destination already exists: $DESTINATION"
exit 1
fi
trucker --move "$SOURCE" "$DESTINATION"
mv "$DESTINATION" "$SOURCE"
git mv "$SOURCE" "$DESTINATION"
git status
echo "Move complete!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment