Helpful & unhelpful scripts.
-
active.app.sh: Logs macOS foreground-app switches as JSON, in real time, with an optional duration arg (defaults to running until interrupted).
-
battery.health.sh: Reports Mac portable battery health, cycle count, max capacity, and hardware/firmware revisions as a Jamf-style
<result>extension attribute. Exits early on non-portable Macs. -
build.pkg.sh: Builds & signs a macOS .pkg via
pkgbuild/productbuild; mode is selected by a required--component/-Cor--distribution/-Dflag. Requires a Developer ID Installer certificate in the keychain (plus a Developer ID Application certificate for--distribution).--componentbuilds a standalone component .pkg;--distributionbuilds a signed, optionally notarized (and optionally .dmg-wrapped) distribution installer. Both modes take optional--scriptsand--component-plistpayloads;--distributionalso takes an optional--resourcespayload and an optional entitlements plist, applied to every re-signed.appin the payload so a build step's own entitlements (e.g. Location Services) survive packaging. -
configure.fleet.printers.sh: Turns a CSV of printers (
name,location,uri,display_name) into a per-printerlpadmininstall script plus the corresponding Fleet GitOpssoftware: packages:YAML entries, ready to paste into a Fleet repo. -
disk.warn.sh: Installs a script + LaunchDaemon that checks free disk space every 60s and shows a warning dialog when it drops below 10%. Must be run as root.
-
fleetctl.update.sh: Upgrades
fleetctlto the latestfleetdm/fleetrelease by downloading and installing its macOS.pkg. Requiresjq. Handy as a shell alias. Must be run as root. -
home.folder.size.sh: Reports top-level folder sizes under the console user's home directory, sorted by path, as a Jamf-style
<result>extension attribute. -
internet.sharing.check.sh: Reports macOS Internet Sharing state: never enabled, disabled-but-configured, or enabled, with source/target interfaces from the NAT plist.
-
jwt.decode.sh: Decodes any JWT (JSON web token) header/payload via
jq(arg or prompt); shows a curated summary for Fleet license JWTs (tier, devices, note, etc.), or dumps all claims withiat/exp/nbfas readable timestamps for anything else. -
lobotomy.sh: Wipes Claude Code's local state: top-level caches/logs/scratch dirs, then per-project session data under
~/.claude/projects, preserving each project'smemoryfolder. An editable array at the top excludes specific project directories entirely. -
macOS.block.app.sh: Installs a LaunchDaemon that kills a named app on launch and shows a blocking dialog; configured for Migration Assistant by default. Re-running is safe (unloads any existing daemon first);
--removeuninstalls it. Must be run as root. -
macOS.update.app.sh: Removes an installed app if its version is older than a given minimum (via zsh's
is-at-least), with a test/dry-run mode. Must be run as root. -
mdm.managed.users.sh: Queries
mdmclientfor MDM management status/active managed users and cross-references GeneratedUID against local accounts to determine which local users are MDM-managed. Must be run as root. -
network.check.sh: Reports network connectivity as a JSON object: active interfaces, primary service name, IPv4/IPv6 gateway & external IP, DNS reachability & resolution, configured DNS servers, Wi-Fi network/signal (when applicable), active VPN tunnels, HTTP/HTTPS/SOCKS/PAC proxy configuration, and captive portal detection. Must be run as root.
-
network.device.list.sh: Reports on devices/connections near this Mac: ARP table, nearby Bonjour services, active outbound connections, & DHCP leases handed out via Internet Sharing.
-
network.quality.sh: Runs macOS's
networkqualitywith a GUI picker (speed test vs. video conferencing) and shows the result in a dialog. Good for Self Service! -
network.service.delete.sh: Deletes network services whose name contains any argument (case-insensitive substring match), then restarts
configd. Handy for stale Internet Sharing entries. Must be run as root. -
reset.desktop.sh: Aggressively closes all Finder windows & force-quits every visible app, to reveal a clean desktop before directing a user to a specific Finder window.
-
set.app.handler.sh: Sets permissions/ownership on an already-installed
swda(SwiftDefaultApps CLI) binary, then uses it to set Microsoft Outlook as the default handler for.icsUTIs, which normally default to Apple Calendar. Must be run as root. -
set.autologin.sh: DANGEROUS! Postinstall for an unattended Mac. Creates a random admin account, enables autologin via
sysadminctl, reboots, then a deferred LaunchDaemon sweeps all other local accounts. Must be run as root. -
set.user.name.sh: Derives the UID 501 user's display name from their
firstname.lastnameshort name and sets RealName to "Firstname Lastname", ComputerName to the short name plus chip & model name, HostName to the short name, and LocalHostName to the short name without the dot. Must be run as root. -
set.user.picture.sh: Replaces a local macOS user account's profile picture via
dscl/dsimport, given a username and image path as args. Must be run as root. -
ubuntu.dconf.sh: Locks down GNOME privacy/security settings (screen lock, idle timeout, location, recent files, trash) system-wide and machine-locked via dconf, so users can't override them with
gsettings. -
ubuntu.privacy.security.sh: Same GNOME privacy/security settings as ubuntu.dconf.sh, but applied per-user via
gsettings(overridable), plus disables Tracker3 file indexing and Apport crash reporting. -
update.marketing.assets.sh: Pulls article metadata from the fleetdm/fleet GitHub repo and prints categorized markdown tables (articles, case studies & announcements, guides) for tracking marketing content.
Some of my ideas in scripts & code aren't posted here. They're in posts on nonpunctual.org: