Skip to content

Instantly share code, notes, and snippets.

@lcenchew
Last active May 29, 2024 05:35
Show Gist options
  • Save lcenchew/402e4004e22367d8021943226a3d0d0b to your computer and use it in GitHub Desktop.
Save lcenchew/402e4004e22367d8021943226a3d0d0b to your computer and use it in GitHub Desktop.
Notes - macOS #notes

macOS

New Mac

Reinstall

https://support.apple.com/en-sg/guide/mac-help/mchlp1599/

Apple silicon:

  • use Erase Assistant to reset your Mac to factory settings
  • Apple menu > Shut Down. Press and hold the power button until “Loading startup options” appears

Intel based:

  • Power on, Alt -> Startup Disk
  • Power on, Command (⌘)-R -> Recovery
  • Power on, Command (⌘)-Option-R -> Internet Recovery (original version of macOS)
  • Power on, Option-⌘-P-R -> reset NVRAM

Download old macOS https://support.apple.com/en-us/HT211683 https://osxdaily.com/where-download-macos-installers/

Create bootable installer https://support.apple.com/en-us/HT201372

Mute Startup Chime

sudo nvram –d SystemAudioVolume

Software Update

softwareupdate --all --install --force

Homebrew

Add a Brewfile

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

brew bundle --file bundle-file

see new macOS setup automation

Add to new users .zprofile

eval "$(/opt/homebrew/bin/brew shellenv)"

Python

brew install python

JDK

using SDKMAN

install

 curl -s "https://get.sdkman.io" | bash

run

source "$HOME/.sdkman/bin/sdkman-init.sh"
sdk version

sdk install java
sdk list

change install JDK version

java -version
export JAVA_VERSION=11
unset JAVA_HOME
java -version

Run from Terminal

open -a ApplicationName

AppleScript

FileVault/Disk Encryption

Restart remotely system using FileVault run this command to restart

sudo fdesetup authrestart

When restart normally, system will wait for password at startup. Remote screen sharing will not be able to connect until the password is entered locally.


launchctl

manage the startup services

launchctl list 

launchctl disable system/

List of startups

cd /Library/LaunchAgents/

dockutil

brew install jq
curl --silent "https://api.github.com/repos/kcrawford/dockutil/releases/latest" > /tmp/curlout
DLURL=$(cat /tmp/curlout | jq -r '.assets | .[0].browser_download_url' | grep pkg)
curl -sL ${DLURL} -o /tmp/dockutil.pkg
sudo installer -pkg "/tmp/dockutil.pkg" -target /

rm /tmp/dockutil.pkg
rm /tmp/curlout

from, edited to

  • fix curl: (23) error
  • fix no match found: .assets[].browser_download_url

Some basics (run as the user)

dockutil -L

Finder

To see hidden files command+shift+.

Time Machine

tmutil listlocalsnapshots /

Console

crash reports

~/Library/Logs/DiagnosticReports/

Portable Disk

touch /Volumes/portableDisk/.metadata_never_index

Power Management

View settings

pmset -g

From man page: hibernatemode = 25 is only settable via pmset. The system will store a copy of memory to persistent storage (the disk), and will remove power to memory. The system will restore from disk image. If you want "hibernation" - slower sleeps, slower wakes, and better battery life, you should use this setting.

reference: https://apple.stackexchange.com/questions/113954/difference-between-autopoweroff-and-standby-in-pmset

standby setting

set standby to 12h after sleep

sudo pmset -a standbydelayhigh 43200
sudo pmset -a standbydelaylow 7200

set autopoweroff to 24h after sleep

sudo pmset -a autopoweroffdelay 86400

After sleeping for seconds, the system will write a hibernation image and go into a lower power chipset sleep.

iTerm2

Screen share

change resolution option + click on Scaled

Chrome Remote Desktop

fix hidden screen

Xcode

xcode-select --install

zsh

To enable completion

brew install zsh-completions

follow the steps to enable and also to fix `zsh compinit: insecure directories`` warnings

.zshrc



🔼

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment