Mac System Specs and Performance Dashboard Bash Script

This script provides an organized summary of your Mac’s system information and performance metrics—including OS details, CPU specifications, memory size, disk usage, uptime, and battery status.

Click to view script…
#!/bin/bash
# system_specs.sh - Display Mac system specs and performance info

# Clear the terminal for a fresh display
clear

echo "======================================"
echo "   Mac System Specs and Performance   "
echo "======================================"

# Operating System Information
os_name=$(sw_vers -productName)
os_version=$(sw_vers -productVersion)
build_version=$(sw_vers -buildVersion)
echo "Operating System: $os_name $os_version (Build $build_version)"

# Computer Name (if set)
computer_name=$(scutil --get ComputerName 2>/dev/null)
if [ -n "$computer_name" ]; then
    echo "Computer Name: $computer_name"
fi

echo "--------------------------------------"

# CPU Information
cpu_brand=$(sysctl -n machdep.cpu.brand_string)
physical_cpu=$(sysctl -n hw.physicalcpu)
logical_cpu=$(sysctl -n hw.logicalcpu)
echo "CPU: $cpu_brand"
echo "Physical Cores: $physical_cpu"
echo "Logical Cores: $logical_cpu"

echo "--------------------------------------"

# Memory (RAM) Information
mem_bytes=$(sysctl -n hw.memsize)
# Convert bytes to gigabytes (1GB = 1073741824 bytes)
mem_gb=$(echo "scale=2; $mem_bytes/1073741824" | bc)
echo "Memory (RAM): $mem_gb GB"

echo "--------------------------------------"

# Disk Usage for the Root Partition
echo "Disk Usage (Root Partition):"
# Display header and the line for '/' partition
df -h / | awk 'NR==1 || $NF=="/"'
echo "--------------------------------------"

# Uptime and Load Average
echo "Uptime and Load Average:"
uptime
echo "--------------------------------------"

# Battery Information (if available)
if command -v pmset &> /dev/null; then
    battery_info=$(pmset -g batt | head -1)
    echo "Battery Info: $battery_info"
fi

echo "======================================"