Skip to content

Instantly share code, notes, and snippets.

@hongsw
Created March 21, 2025 02:09
Show Gist options
  • Save hongsw/39552ac7807bdac2f025f3b84951a4f4 to your computer and use it in GitHub Desktop.
Save hongsw/39552ac7807bdac2f025f3b84951a4f4 to your computer and use it in GitHub Desktop.

Revisions

  1. hongsw created this gist Mar 21, 2025.
    23 changes: 23 additions & 0 deletions update-asdf-0.16-zshrc.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    #!/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."