Created
March 21, 2025 02:09
-
-
Save hongsw/39552ac7807bdac2f025f3b84951a4f4 to your computer and use it in GitHub Desktop.
Purpose of the Script This script automates the configuration changes required when upgrading to ASDF version 0.16.0 from earlier versions. The purpose is to: Safely back up the user's existing .zshrc configuration file Remove any outdated ASDF-related configuration lines Add the new required environment variables and PATH modifications for ASDF…
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Create backup filename with current date and time | |
BACKUP_FILE=~/.zshrc.backup.$(date +%Y%m%d%H%M%S) | |
# Backup original file | |
cp ~/.zshrc "$BACKUP_FILE" | |
echo "Existing .zshrc file has been backed up to $BACKUP_FILE" | |
# Remove existing ASDF-related settings and create new file | |
grep -v "asdf\|ASDF_DATA_DIR" ~/.zshrc > ~/.zshrc.new | |
# Add new ASDF settings | |
echo 'export ASDF_DATA_DIR="$HOME/.asdf" && export PATH="$ASDF_DATA_DIR/shims:$HOME/bin:$PATH"' >> ~/.zshrc.new | |
# Replace original file | |
mv ~/.zshrc.new ~/.zshrc | |
# Output changes | |
echo -e "\nChanges made:" | |
diff "$BACKUP_FILE" ~/.zshrc | |
echo -e "\nSetup complete. Run 'source ~/.zshrc' or open a new terminal to apply changes." |
Author
hongsw
commented
Mar 21, 2025
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment