Skip to content

Instantly share code, notes, and snippets.

@troutcolor
Created November 23, 2024 17:20
Show Gist options
  • Save troutcolor/9657199b10666f277d8b7aae662e9d79 to your computer and use it in GitHub Desktop.
Save troutcolor/9657199b10666f277d8b7aae662e9d79 to your computer and use it in GitHub Desktop.
Script to get mac and os, current app and version info and put it on the clipboard
#!/bin/bash
# Get computer model
MODEL=$(sysctl -n hw.model)
# Get OS version
OS_VERSION=$(sw_vers -productVersion)
# Get frontmost app and its version
FRONT_APP=$(lsappinfo info -only name `lsappinfo front | sed 's/-/-0x/'` | cut -d '"' -f 4)
APP_VERSION=$(osascript -e "tell application \"$FRONT_APP\" to get version" 2>/dev/null || echo "Version unknown")
# Create report
REPORT="Computer Model: $MODEL
macOS Version: $OS_VERSION
Current Application: $FRONT_APP
Application Version: $APP_VERSION"
# Copy to clipboard
echo "$REPORT" | pbcopy
# Optional: Also print to terminal
echo "$REPORT"
echo -e "\nReport copied to clipboard!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment