#!/usr/bin/env bash set -euo pipefail echo "Device info:" hw_profiler="$(system_profiler SPHardwareDataType 2>/dev/null)" chip="$(printf '%s\n' "$hw_profiler" | awk -F': ' '/Chip:/{print $2; exit}')" if [[ -z "$chip" ]]; then chip="$(printf '%s\n' "$hw_profiler" | awk -F': ' '/Processor Name:/{print $2; exit}')" fi if [[ -z "$chip" ]]; then chip="Unknown" fi echo "$chip" ioreg -l | grep -E '"DesignCapacity" =|"AppleRawMaxCapacity"' | grep -o '[0-9]*' | tr '\n' ',' | awk -F"," '{print (int(($2/$1)*1000 + 0.5)/10 "% battery health")}' mem="$(printf '%s\n' "$hw_profiler" | awk -F': ' '/Memory:/{print $2; exit}')" if [[ -z "$mem" ]]; then mem_bytes="$(sysctl -n hw.memsize 2>/dev/null || true)" if [[ -n "$mem_bytes" ]]; then mem="$(awk -v b="$mem_bytes" 'BEGIN { if (b>0) printf "%.0f GB", b/1073741824 }')" fi fi if [[ -z "$mem" ]]; then mem="Unknown" fi echo "$mem" serial="$(printf '%s\n' "$hw_profiler" | awk -F': ' '/Serial Number \(system\):/{print $2; exit}')" if [[ -z "$serial" ]]; then serial="Unknown" fi echo "$serial" echo "$(sw_vers -productName) $(sw_vers -productVersion)"