Skip to content

Instantly share code, notes, and snippets.

@kristw
Last active October 6, 2023 23:18
Show Gist options
  • Save kristw/0097e96e5a3641c79482d9d81118d2a5 to your computer and use it in GitHub Desktop.
Save kristw/0097e96e5a3641c79482d9d81118d2a5 to your computer and use it in GitHub Desktop.
#!/bin/bash
func install_yamlfmt {
# Check the machine architecture
arch=$(uname -m)
# Set the URL based on the machine architecture
if [[ $arch == "x86_64" ]]; then
url="https://github.com/google/yamlfmt/releases/download/v0.10.0/yamlfmt_0.10.0_Linux_x86_64.tar.gz"
elif [[ $arch == "arm64" ]]; then
url="https://github.com/google/yamlfmt/releases/download/v0.10.0/yamlfmt_0.10.0_Linux_arm64.tar.gz"
else
echo "Unsupported architecture: $arch"
exit 1
fi
# Create a temporary directory
temp_dir=$(mktemp -d)
# Download the file using curl
curl -L "$url" -o "$temp_dir/yamlfmt.tar.gz"
# Extract the contents of the tar file
tar -xzvf "$temp_dir/yamlfmt.tar.gz" -C "$temp_dir"
# Move the yamlfmt file to the destination
mkdir -p "$HOME/.local/bin"
mv "$temp_dir/yamlfmt" "$HOME/.local/bin/yamlfmt"
# Clean up the temporary directory
rm -rf "$temp_dir"
echo "yamlfmt installation complete!"
}
install_yamlfmt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment