Created
May 7, 2025 21:32
-
-
Save walmsles/b4727e21d20e95826742143a1471aeaf to your computer and use it in GitHub Desktop.
Install Amazon Q Cli
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 | |
| set -e | |
| # Script to download, unzip and install CodeWhisperer Q CLI tool | |
| echo "Starting installation of Q CLI tool..." | |
| # Create temporary directory | |
| TEMP_DIR=$(mktemp -d) | |
| echo "Created temporary directory: $TEMP_DIR" | |
| # Ensure cleanup on exit | |
| cleanup() { | |
| echo "Cleaning up temporary files..." | |
| rm -rf "$TEMP_DIR" | |
| echo "Cleanup complete." | |
| } | |
| # Register the cleanup function to be called on script exit | |
| trap cleanup EXIT | |
| # Download the file to the temporary directory | |
| echo "Downloading Q CLI tool..." | |
| curl --proto '=https' --tlsv1.2 -sSf https://desktop-release.codewhisperer.us-east-1.amazonaws.com/latest/q-x86_64-linux-musl.zip -o "$TEMP_DIR/q.zip" | |
| if [ $? -ne 0 ]; then | |
| echo "Download failed. Please check your internet connection and try again." | |
| exit 1 | |
| fi | |
| echo "Download completed successfully." | |
| # Unzip the file | |
| echo "Extracting files..." | |
| unzip -q "$TEMP_DIR/q.zip" -d "$TEMP_DIR" | |
| if [ $? -ne 0 ]; then | |
| echo "Failed to extract the zip file." | |
| exit 1 | |
| fi | |
| # Check if q executable exists in the extracted files | |
| Q_INSTALLER=$(find "$TEMP_DIR" -name "install.sh" -type f -executable) | |
| if [ -z "$Q_INSTALLER" ]; then | |
| # If not found as executable, find any file named q | |
| Q_INSTALLER=$(find "$TEMP_DIR" -name "install.sh" -type f) | |
| if [ -z "$Q_INSTALLER" ]; then | |
| echo "Could not find the Q executable in the extracted files." | |
| echo "Contents of the extracted directory:" | |
| ls -la "$TEMP_DIR" | |
| exit 1 | |
| fi | |
| # Make it executable | |
| chmod +x "$Q_INSTALLER" | |
| fi | |
| echo "Found Q installer at: $Q_INSTALLER" | |
| $Q_INSTALLER | |
| echo "Installation completed successfully!" | |
| echo "You can now run Q CLI tool using: q" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment