# macOS
## Keyboard Shortcuts
| Shortcut | Action |
| ----------------------- | ------------------------------------------------ |
| `Cmd+Opt+D` | Hide/show the Dock |
| `Cmd+click` on Dock app | Reveal app in Finder |
| `Cmd+F1` | Toggle display mirroring |
| `Cmd+Opt+Shift+K` | Switch to next input source |
| `Cmd+Ctrl+Space` | Open emoji and symbols picker at cursor |
| ``Cmd+` `` | Switch between open windows of the active app |
| `Ctrl+↓` | View all open windows of the active app |
| `Cmd+Opt+H` | Hide all windows except the active one |
| `Ctrl+Fn+C` | Center the active window (macOS Sequoia) |
| `Cmd+B` | Search from Spotlight directly in search engine |
| `Opt+Delete` | Delete the last word from cursor position |
| `Opt` (hold) | Show clickable folder navigation bar in Finder |
| `F5` | Autocomplete words (system-wide text completion) |
## Useful Commands
### Remove Empty Folders
```bash
find . -name '.DS_Store' -type f -print -delete
find . -type d -empty -print -delete
```
### List File Providers
```bash
fileproviderctl domain list
```
### Gatekeeper: Quarantine Attributes
```bash
# Check quarantine status
xattr -l /path/to/app
# Remove quarantine (allow unsigned app to run)
xattr -d com.apple.quarantine /path/to/app
# Restore quarantine
xattr -w com.apple.quarantine "0291;..." /path/to/app
```
[Source](https://apple.stackexchange.com/questions/376629)
## Temporary Directory Cleanup
macOS has two main temp locations, both cleaned automatically:
- **`/tmp`** (symlink to `/private/tmp`) — flushed on **reboot**, and also cleaned daily by the `110.clean-tmps` periodic script (files not accessed for 3 days are deleted). Log output in `/var/log/daily.out`.
- **`/var/folders/`** (per-user temp space, used by `mktemp` / `$TMPDIR`) — cleaned by the **`dirhelper`** daemon (runs daily at 3:35 AM, removes files not accessed for 3 days).
Both use a **3-day access-time threshold**. Don't rely on either location for persistent storage.
Sources:
- [How temporary files are removed on MacOS — David Winterbottom](https://til.codeinthehole.com/posts/how-temp-files-are-removed-on-macos/)
- [What is "/var/folders"? — Magnusviri](https://magnusviri.com/what-is-var-folders.html)
- [Apple Developer Forums](https://developer.apple.com/forums/thread/71382)
## macOS Keychain for Secrets
Store and retrieve secrets via the `security` command. Works but doesn't sync across devices (see [[1Password]] for the `op run` approach instead).
```bash
# Store
security add-generic-password -a "$USER" -s 'OPENAI_API_KEY' -w 'the-key'
# Retrieve
security find-generic-password -a "$USER" -s 'OPENAI_API_KEY' -w
# Use in .zshrc
OPENAI_API_KEY=$(security find-generic-password -a "$USER" -s "OPENAI_API_KEY" -w)
```
[Source](https://medium.com/@johnjjung/how-to-store-sensitive-environment-variables-on-macos-76bd5ba464f6)
## Related Notes
- [[macOS - Time Machine]]