# MacOS - [Why is the M1 So Fast](https://readwise.io/reader/shared/01gfw3kj3vk8tbrfjezhqk9a5y) - [macos-defaults](https://macos-defaults.com/) ## essential things to make [[MacOS]] more like [[Linux]] ### Bootstrap ```bash brew install \ coreutils findutils gnu-tar gnu-sed gawk gnutls gnu-indent gnu-getopt grep tree watch \ bash \ vim \ docker \ htop \ iproute2mac # restore .profile .bashrc .bash_profile # add /opt/homebrew/bin/bash to /etc/shells chsh -s $(which bash) # turn off accent repeats defaults write -g ApplePressAndHoldEnabled -bool false ### command equivalents | [[Linux]] | [[MacOS]] | Note | | ---------------- | ------------- | ---- | | `ld` | `otool -L` | | | `netstat -lnput` | `lsof -i` | | | `route -n` | `netstat -nr` | | ## Common Shortcuts | shortcut | description | | ----------------------------------------- | ----------- | | <kbd>⌘</kbd>+<kbd>Ctrl</kbd>+<kbd>q</kbd> | lock | ## Screenshot Shortcuts | shortcut | description | | --------------------- | ----------------------------------- | | Shift + ⌘ + 3 | whole screen | | Shift + ⌘ + 4 | quick select area | | Shift + ⌘ + 4 + Space | window | | Shift + ⌘ + 5 | full interactive screenshot overlay | | Ctrl + ⌘ + esc | stop recording | | Shift + ⌘ + 6 | snapshot touch bar | ## [[Tiling Window Managers]] some from [review](https://forum.zettelkasten.de/discussion/1518/tiling-window-managers-on-macos) - [AeroSpace](https://nikitabobko.github.io/AeroSpace/guide) - promising new i3-like manager - **Amethyst [https://ianyh.com/amethyst/](https://ianyh.com/amethyst/)** ([open source](https://github.com/ianyh/Amethyst)): Easy to install, offers shortcuts to tile windows, based on "binary partitioning" (aka you are constantly halving the spaces) - [comparing Amethyst and chunkwm](https://thesweetsetup.com/apps-were-trying-alternative-window-managers-for-macos/) - **yabai [https://github.com/koekeishiya/yabai](https://github.com/koekeishiya/yabai)** (free/open source): apparently also removes the window chrome, aka the window title?! Doesn't come with shortcuts, you have to use another app for shortcuts and then invoke the yabai functions. You can use [[Hammerspoon]] or a small keyboard shortcut tool called [skhd](https://github.com/koekeishiya/skhd) or whatever you already have on your system. yabai is controlled via [command line message sending](https://github.com/koekeishiya/yabai/wiki/Commands#message-passing-interface). - **chunkwm [https://github.com/kylef/chunkwm/](https://github.com/kylef/chunkwm/)** (free/open source): code base is older, apparently abandoned, but you can find articles on the web about "chunkwm" and can get a glimpse into what to do with yabai, more like [[i3]] - [Making the best of OSX with chunkwm](https://medium.com/@douglasshooker/tiling-your-windows-on-osx-92ac20453560) - **slate** <https://github.com/jigish/slate> open source, configurable replacement for size-up ## keyboard ### Karabiner Elements Config - leave stock except for `CapsLock` -> `fn` for select devices? #### config `~/Dropbox/backup.tmp/.config/karabiner/karabiner.json` #### Devices ![[Uo_kREbzfO.png]] ![[E8_9E1cenv.png]] ### OS Config #### Use Globe/fn The Mac keyboard <kbd>Globe/fn</kbd> key does not send a USB scancode (it's a layer switch), which is why QMK and other keyboard firmware can't use it. The work-around is to soft-issue <kbd>Globe/fn</kbd> using another key. `System Preferences / Keyboard / Modifier Keys / Ergodox EZ Glow` - set <kbd>Caps Lock</kbd> to <kbd>🌐/fn</kbd>. In combination with Contexts app switcher, can use <kbd>Caps Lock</kbd> hold as a trigger for <kbd>Globe/fn</kbd> to quickly search open apps. ### Control/Escape mapping with Hammerspoon <https://github.com/jasonrudolph/ControlEscape.spoon> ### Open iTerm from Finder <https://github.com/peterldowns/iterm2-finder-tools> Add keyboard shortcut `CTRL-SHIFT-OPT-CMD-O` ### enable Touch ID for `sudo` ```bash sudo gsed -i '2s/^/auth sufficient pam_tid.so\n/' /etc/pam.d/sudo ``` #### Touch ID with [[tmux]] <https://github.com/fabianishere/pam_reattach> ```bash brew install pam-reattach sudo gsed -i "2s|^|auth optional $(brew --prefix)/lib/pam/pam_reattach.so\n|" /etc/pam.d/sudo ``` ## Troubleshooting ### [[USE Method]] ![[USE Method#MacOS]] ### remove hidden attribute on file ```bash xattr -d com.apple.FinderInfo ~/Library chflags nohidden ~/Library ``` ### Fixing broken `/etc/pam.d/sudo` file 1. copy `/etc/pam.d/sudo` file to home 2. make edits 3. use Finder, drag-n-drop edited file to `/etc/pam.d`; Finder does not use the `sudo` file for privilege escalation. ### Reset System Management Controller (SMC) #### MacBook with T2 Chip 1. Shut down the computer 1. Press and hold the following keys: 1. Control on the left side of keyboard 1. Option on the left side of keyboard 1. Shift on the right side of keyboard 1. Keep holding all 3 keys for 7 seconds, then press & hold power button, Note: if MacBook is turning on, MacBook will turn off by itself 1. Keep holding all 4 keys for 7 seconds, then release all keys 1. Wait a few seconds then use power button to turn on MacBook ### Reset NVRAM 1. shut down 1. Press and hold: `Option + Cmd + P + R`; you can release after 20 seconds. 1. When your Mac finishes starting up, you might want to open System Preferences and adjust any settings that were reset, such as sound volume, display resolution, startup disk selection, or time zone. ### find what is taking power, preventing sleep ``` pmset -g assertions ``` ### Change `ComputerName` #protip ```bash sudo scutil --set ComputerName dog1 ``` ### Power Management [source article](https://computers.tutsplus.com/tutorials/how-to-hibernate-a-mac--cms-23235) #### hibernatemode - `hibernatemode=0` by default is supported on desktops. The system will not back memory up to persistent storage. The system must wake from the contents of the memory (RAM). The system will lose context on power loss. Historically, this is plain old sleep. - `hibernatemode=3` by default is supported on portables or laptops. The system will store a copy of memory to persistent storage (the disk), and will power memory during sleep. The system will wake from memory, unless a power loss forces it to restore from disk image. - `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. ```bash sudo pmset -b hibernatemode 25 ``` ### System Settings/Permissions ```bash # admin-mode all the settings security authorizationdb write system.preferences is-admin ``` #### standbydelay `standbydelay` specifies the delay, in seconds, before writing the hibernation image to disk and powering off memory for Standby. ```bash sudo pmset -b standbydelay 600 ``` ### System Integrity Protection (SIP) - [selectively disable SIP](x-devonthink-item://8B79DD37-9405-4BDB-8ED2-538025063F3A) to enable [[dtrace]] ### Spotlight Flaky Rebuild spotlight indexes ```bash sudo mdutil -E / ``` ### MacOS Sequoia, remove screen shot permissions nag prompt https://apple.stackexchange.com/questions/475540/how-to-stop-allow-for-one-month-in-macos-15-sequoia-especially-when-replayd ### Running Windows on M1 Macs M1[-(Pro|Max)] is an [[ARM]] or aarch64 architecture mac. - [General instructions](https://mac.getutm.app/gallery/windows-11-arm) - For UTM 2.4, above instructions need modified - use qcow2 conversion and not the VHDX image directly (see Troubleshooting) - When Creating the VM - Modify *System* options ([source](https://github.com/utmapp/UTM/issues/3130#issuecomment-958553746)) - Architecture: aarch64 - Show Advanced Options: checked - CPU: Default - CPU Cores: Explicitly Set - Force Multicore: unchecked - QEMU Machine Properties: `highmem=off,virtualization=on` [Another Set of Steps Using the UUP Dump Method](https://jensd.be/1533/windows/windows-11-arm-on-m1-based-macs-with-utm)