macOS
Name | Character | kbd | Physical key |
---|---|---|---|
Command | ⌘ | ⌘ | ⊞ Windows |
Control | ⌃ | ⌃ | Ctrl |
Shift | ⇧ | ⇧ | Mayús |
Option / Alt | ⌥ | ⌥ | Alt |
Escape | ⎋ | ⎋ | Esc |
Advanced macOS Command-Line Tools - https://saurabhs.org/advanced-macos-commands
What prevents Mac to sleep: pmset -g assertions
. See https://osxdaily.com/2012/07/11/mac-wont-sleep-heres-how-to-find-out-why-and-fix-it
Keyboard Shortcuts
Cycle current application’s windows: ⌘ + `
Character Viewer (emoji picker): ⌘ + Ctrl + Space
Show/hide hidden files: ⌘ + Shift + .
All my macOS keyboard shortcuts - https://www.jamieonkeys.dev/posts/keyboard-shortcuts - https://news.ycombinator.com/item?id=30876934
Add sleep shortcut
https://apple.stackexchange.com/a/431149/241238
Monterey: Preferències → Teclat → pestanya Dreceres → Dreceres de l'app. Ventura: Configuració → Teclat → Dreceres de teclat... → Dreceres de l'app. Afegir 2 dreceres noves amb nom 'Sleep' i 'Repòs' a ShiftAltQ. Haig de veure el shortcut ⌥⇧Q al menu del sistema.
Prevent ⌘+i to open the Mail app on Chrome
Ventura: Configuració → Teclat → Dreceres de teclat... → Dreceres de l'app. Clicar '+'. Al menú que s'obre seleccionar:
- App: Google Chrome.
- Títol de menú: ha de ser exactament "Envia l'enllaç per correu electrònic". És el que diu a Chrome → Fitxer → Comparteix.
- Drecera de teclat: qualsevol cosa, per exemple ⌃⌥⇧⌘E.
DefaultKeyBinding.dict
{
"^u" = "deleteWordBackward:";
"^o" = "deleteWordForward:";
"^j" = "moveWordBackward:";
"^l" = "moveWordForward:";
}
Place this file in ~/Library/KeyBindings/
(create the folder if it doesn't exist yet).
Note that you need to restart the apps to take effect (eg run killall Finder
to restart Finder, close and open Firefox etc.).
Examples:
- http://xahlee.info/kbd/osx_keybinding_action_code.html
- https://gist.github.com/trusktr/1e5e516df4e8032cbc3d
- https://github.com/ttscoff/KeyBindings
iTerm2
Color schemes
https://iterm2colorschemes.com - https://github.com/mbadolato/iTerm2-Color-Schemes
Changed in Settings → Profiles → Colors, at the dropdown 'Color presets...'. Tip: duplicate the current profile to make tests.
Finder integration (New iTerm Window here)
Click the 'iTerm2' menu bar item (at the top left) and then do Services → Services Settings... This opens the 'Configuració del Sistema' → Teclat → Dreceres de teclat... Once there, on 'Arxius i carpetes' check 'New iTerm Window here'.
Shortcuts
I've already added these shortcuts in the past. Thus, to have them in a new iTerm2 installation, I don't have to add them manually again, I can simply import either the profile .json file or the .itermkeymap file.
Note that the .json profile contains all the shortcuts of the .itermkeymap file, so if we import the profile we don't have to import the .itermkeymap afterwards.
Go to Preferences → Profiles tab → Keys tab → Key Mappings tab. Click the + button.
Shortcuts | Description | Action | Send |
---|---|---|---|
Alt+← Ctrl+j | Move word left | Send Escape Sequence | b |
Alt+→ Ctrl+l | Move word right | Send Escape Sequence | f |
Ctrl+u | Delete word left | Send Hex Codes | 0x1b 0x08 (could instead be 0x17, see StackOverflow below) |
Ctrl+o | Delete word right | Send Hex Codes | 0x1b 0x64 |
"send hex code" vs "send escape sequence"
From https://sergeemond.ca/en/articles/iterm-extend-send-text-action
- “send escape sequence” simply sends a “\e” followed by the text as-is
- “send hex code” scans for one 8-bit code, and sends that
- “send text” allows for “\e” (escape), “\n” (newline), “\a” (bell), and “\t” (tab), and normal text
Shortcuts and tricks
- Undo close: when you close a session tab by accident, you can restore it with Edit → Undo or Cmd+Z.
- Important: adjust the timeout in Settings → Profiles → Session, at "Undo can revive a session that has been closed for up to X seconds". Default value is 5 seconds. Should be changed to about 25 seconds.
- Hold Cmd+Option to select text with the mouse doing a rectangle
kexts
Used by Little Snitch and Razer Synapse.
Are located in /Library/Extensions/
.
Free up disk space
- This frees plenty GBs Android emulators, system images, SDKs, build tools, NDK etcetera:
- To get rid of Android emulators, open Android Studio → Device Manager and delete them.
- To get rid of Android system images, SDKs and other stuff, open Android Studio → SDK Manager. (There are various ways to open it, eg Settings → Languages & Frameworks → Android SDK). Once thee, check the checkbox 'Show package details'. Then uninstall everything possible like the NDK, emulator System Images, SDKs etcetera.
- Delete
node_modules
folders with npkill:npx npkill@latest --directory ~/Programming
.npx npkill@latest --directory ~/Webs
.
- Delete
build
folders:find . -type d -name "build" -exec rm -rf {} +
. - Delete Python
venv
folders:find . -type d -name "venv" -exec rm -rf {} +
. - Delete
.terraform
folders. The aws provider is 580 MB. See instructions - Xcode
- Delete unused simulators data in
~/Library/Developer/CoreSimulator/Devices
:xcrun simctl delete unavailable
. From https://stackoverflow.com/a/42703818/4034572. - Delete Xcode caches with 'DevCleaner for Xcode' - https://apps.apple.com/us/app/devcleaner/id1388020431.
- Delete Xcode caches with Storage app (Sobre aquest Mac → Emmagatzematge → Gestionar... i seleccionar Desenvolupador al menú de l'esquerra) - https://stackoverflow.com/a/69623427/4034572
- Delete old Xcode archives. Use the Organizer (Window → Organizer).
- Delete unused simulators data in
- JetBrains IDEs, delete old versions: Help → Delete Leftover IDE Directories…
- JetBrains IDEs are located at
~/Library/Application Support/JetBrains
(cd ~/Library/Application\ Support/JetBrains
). - There are also really big files at
~/Library/Caches/JetBrains
. - Directories are listed at the uninstall instructions: https://www.jetbrains.com/help/idea/uninstall.html#macos.
- Android Studio is located at
~/Library/Application Support/Google
(cd ~/Library/Application\ Support/Google
).
- JetBrains IDEs are located at
- Docker:
- Docs: Prune unused Docker objects: https://docs.docker.com/config/pruning.
- Remove dangling images (images with
<none>
indocker image ls
):docker image prune
(docs)- IMPORTANT: be careful with
docker image prune -a
because it deletes plenty of stuff, eg it has deleted all images shown bydocker image ls
, not only the ones with<none>
! It saysWARNING! This will remove all images without at least one container associated to them.
.
- IMPORTANT: be careful with
- Pune everything:
docker system prune
. This removes all stopped containers, all networks not used by at least one container, all dangling images and all build cache.
- Anar a
~/Library/Application Support
i esborrar programes antics. - Esborrar fitxers grans: Sobre aquest Mac → Emmagatzematge → Gestionar...
- Telegram: esborrar la memòria cau (pot tenir 1 GB). Es fa a Configuració → Dades i emmagatzematge → Ús de l'emmagatzematge
- Firefox: esborrar dades del lloc (pot ser 3 GB). Anar a Preferències → Privadesa i seguretat → Gestiona les dades... S'ordenen per mida. Cal apretar Delete a cada Lloc i després 'Desa els canvis' (sinó no esborra). Esborrar les que fa més d'un any que es van fer servir ('Darrer ús').
brew autoremove
: uninstall formulae that were only installed as a dependency of another formula and are now no longer needed.brew cleanup
: usually not necessary, but sometimes frees space.