# MacOS
# Introduction
- docs
# Commons
right click —
⌃
click
home / end
fn
←
and→
⌘
←
and→
— move the insertion point- backwards / forwards in Chrome
⌥
↑
and↓
—ctrl
home / end when edit- first / last item in Finder
⌘
↑
and↓
—ctrl
home
orctrl
end
in Windows- move around folder in Finder
page up / down
fn
↑
and↓
ctrl
arrow
in Windows —⌥
←
and→
⌘
⌘
g
— find next, with⇧
to find previous⌘
e
in Chrome — use selection for find
⌥
⌘
esc
— in the Apple menu⌘
␣
— Spotlight⌘
l
— dictionary⌘
— show path- Spotlight keyboard shortcuts on Mac - Apple Support (opens new window)
⌃
⌘
␣
— emojis and symbols⌃
⌘
d
— the definition of the selected word- Spelling
⇧
⌘
:
— Display the Spelling and Grammar window⌘
;
— Find misspelled words in the document.
⌥
⌘
f
— Show or hide a toolbar in the app⌥
⌘
i
— Show or hide the inspector window⌘
+
,⌘
-
,⌘
0
— zoom⇧
⌘
?
— help
# Edit
edit
- backspace (
^?
) and delete- del —
fn
delete
⌥
delete
,⌥
backspace
— delete word
- del —
- align
⌃
[
— left align⌃
]
— right align⇧
⌃
\
— center align
- from emacs
⌃
h
,⌃
d
— backward-delete-char, delete-char-or-list⌃
k
⌃
y
— yank⌃
a
,⌃
e
— beginning-of-line, end-of-line⌃
f
,⌃
b
— backward-char, forward-char⌃
l
— Center the cursor or selection in the visible areaclear
in Terminal
⌃
p
,⌃
n
⌃
o
— Insert a new line after the insertion point, cursor stays⌃
t
— swap character
- backspace (
input method
- change order of input sources — tbd
- emoji, Keyboard viewer — in the input menu, or
⌃
⌘
␣
- popup for accented alphabet — hold the key
- disable popup —
defaults write -g ApplePressAndHoldEnabled -bool false
- disable popup —
- alternative keyboard — hold
⌥
, optionallyshift
- show alternative keyboard layout — System Preferences > Keyboard > Input Sources, hold
⌥
key - dead key (opens new window)
⌥
e
— á, é, í, ó, ú⌥
~
— à, è, ì, ò, ù⌥
u
— ä, ë, ï, ö, ü, ÿ⌥
i
— â, ê, î, ô, û⌥
n
— ã, õ, ñ⌥
c
— ç
- show alternative keyboard layout — System Preferences > Keyboard > Input Sources, hold
- unicode hex input method — hold
⌥
to input chars by unicode hex - dash
- en dash —
option
-
- em dash —
shift
option
-
- Windows —
alt
0150
andalt
0151
- en dash —
- Chinese input method
- 拆字 —
shift + ␣
- 拆字 —
edit in Terminal —
bindkey -M main
,⌥
oresc
(^[
) as meta key- docs
- arguments — most commands support argument for repeating
⌥
number
— digit-argument⌥
-
— neg-argument
- movement
⌥
left click^x
⌃
f
— vi-find-next-char^x
⌃
b
— vi-match-bracket⌥
⇧
|
(vim:|
) — vi-goto-column, use with number argument⌥
b
,⌥
f
— backward-word, forward-word⌃
a
,⌃
e
— beginning-of-line, end-of-line⌃
n
,⌃
p
— down-line-or-history, up-line-or-history
- history
⌥
⇧
<
(vim:gg
),⌥
⇧
>
— beginning-of-buffer-or-history, end-of-buffer-or-history⌃
n
,⌃
p
— down-line-or-history, up-line-or-history⌥
p
,⌥
n
— history-search-backward, history-search-forward^x
⌃
n
— infer-next-history, search in the history list for a line matching the current one and fetch the event following it⌥
.
,⌥
-
— insert-last-word, use with positive and negative (can be-0
) argument, loop through previous lines when used consecutively⌥
,
,⌥
/
— _history-complete-newer, _history-complete-older, Complete words from the history- search
- keymap —
bindkey -M isearch
⌃
r
,^x
r
— history-incremental-search-backward, reverse search, a second⌃
r
recalls the previous search⌃
s
,^x
s
— history-incremental-search-forward- supported functions
- accept-*
- backward kill or delete
- history-incremental-search-forward, history-incremental-search-backward — find next occurrence or invert search
- quote-insert
- vi prefixed version of the above and vi-cmd-mode, vi-repeat-search, vi-rev-repeat-search
- exit — send-break restores, movement commands retains
- keymap —
- modifying text
- kill
⌃
h
,⌃
d
— backward-delete-char, delete-char-or-list, in Terminalexit
if no character when⌃
d
⌃
w
or⌥
⌃
h
,⌥
d
— backward-kill-word, kill-word⌃
k
,⌃
u
— kill-line, kill-whole-line (remapped to backward-kill-line)^x
⌃
k
— kill-buffer
- yank
⌃
y
— yank⌥
y
— yank-pop, cycle though previously yanked
- transpose
⌃
t
— transpose-chars⌥
t
— transpose-words
- case
⌥
c
,⌥
l
(remapped tols^J
) — capitalize-word, down-case-word⌥
u
— up-case-word
- join
^x
⌃
j
— vi-join
- selection region
⌥
w
— copy-region-as-kill^x
,⌃
x
— exchange-point-and-mark⌥
"
— quote-region⌃
@
— set-mark-command, Set the mark at the cursor position, also mapped to⌃
␣
- kill
- insert
⌃
i
,⌥
⌃
i
— expand-or-complete, self-insert-unmeta,\t
⌃
m
,⌥
⌃
m
— accept-line, self-insert-unmeta,\r
⌃
j
,⌥
⌃
j
— accept-line, self-insert-unmeta,\n
⌃
v
— quoted-insert, control sequence,⌃
v
+⌃
h
types "^H", a literal backspace⌥
.
,⌥
-
— insert-last-word, use with positive and negative (can be-0
) argument, loop through previous lines when used consecutively⌥
⌃
-
— copy-prev-word⌥
m
— copy-prev-shell-word⌥
"
— quote-region⌥
'
— quote-line^x
⌃
r
— _read_comp (opens new window), set the variable_read_comp
or insert if already set^x
m
— _most_recent_file, supports globbing
- mode
^x
⌃
o
— overwrite-mode^x
⌃
v
— vi-cmd-mode^x
⌃
e
— edit-command-line, edit line in vim⌥
x
— execute-named-cmd, keymapbindkey -M command
⌥
z
— execute-last-named-cmd
⌃
g
,⌥
⌃
g
— send-break, Abort the current editor function: Abort the research and restore the original line⌃
l
— clear-screen- buffer — registers in vim
- the ‘yank’ buffer
"0
, the nine ‘queued’ buffers"1
to"9
— If no buffer is specified for a cut or change command,"1
is used, and the contents of"1
to"8
are each shifted along one buffer; the contents of"9
is lost. If no buffer is specified for a yank command,"0
is used - the 26 ‘named’ buffers
"a
to"z
— If a named buffer is specified using a capital, the newly cut text is appended to the buffer instead of overwriting it - the ‘black hole’ buffer
"_
— When using the"_
buffer, nothing happens. This can be useful for deleting text without affecting any buffers
- the ‘yank’ buffer
- completion
⌃
d
— delete-char-or-list, If the cursor is at the end of the line, list possible completions for the current word⌥
⌃
d
— list-choicestab
,⌃
i
— expand-or-complete^x
n
— _next_tags, basically same astab
?⌃
@
— autosuggest-accept (also mapped to⌃
␣
)- deprecated — use below instead
- accept — history-search-backward, forward-char, end-of-line
- partial accept — forward-word
- spelling
⌥
$
,⌥
s
— spell-word, Attempt spelling correction on the current word^x
c
— _correct_word, spell correction, with choice selection
- expand or print
tab
— expand-or-complete⌥
␣
,⌥
!
— expand-history (!!
for example)^x
⇧
*
,^x
e
— expand-word ($PATH
expands to the path), _expand_word (with completion selection)^x
g
,^x
d
— list-expand, _list_expansions,echo
that word^x
a
— _expand_alias^x
=
—ga
in vim, what-cursor-position, print char code
- accept or buffer stack
⌃
m
,⌃
j
— accept-line⌃
o
— accept-line-and-down-history, Executes the found command from history, and fetch the next line relative to the current line from the history for editing⌥
a
— accept-and-hold, Push the contents of the buffer on the buffer stack and execute it⌃
q
,⌥
q
— push-line, remapped to push-line-or-edit⌥
h
— run-help, Push the buffer onto the buffer stack, and execute the commandrun-help cmd
, where cmd is the current command,run-help
is normally aliased toman
⌥
⇧
?
— which-command, push current andwhich-command cmd
,which-command
is normally aliased towhence
⌥
g
— get-line, Pop the top line off the buffer stack and insert it at the cursor position
- undo
⌃
-
,^x
u
,^x
⌃
u
— undo⌃
r
in vim — redo
# System
navigation — snap aware, in System Preferences > Keyboard > Shortcuts > Keyboard
- switch navigation on / off —
⌃
F1
- menu bar navigation —
⌃
F2
- dock navigation —
⌃
F3
- hide dock —
⌥
⌘
d
- hide dock —
- move focus to active or next window —
^
F4
- move focus to window toolbar —
^
F5
- move focus to the floating window —
^
F6
- change the way Tab moves focus —
^
F7
- move focus to status bar —
^
F8
- switch navigation on / off —
windows
⌘
h
— Hide the windows of the front app. PressCommand-Option-H
to view the front app but hide all other apps.- invisible in mission control
⌘
m
— Minimize the front window to the Dock. PressCommand-Option-M
to minimize all windows of the front app.⌘
tab
can switch to a minimized app but windows of the app will stay minimized- invisible in mission control
⌘
w
⌥
⌘
w
— all windows⇧
⌘
w
— all tabs of this window
⌃
⌘
f
— fullscreen⌘
tab
— app switcher- can use arrow keys to switch and show application windows
- use
h
to hide andq
toquit
- drag aware
⌘
~
- switch between windows of the same app
- switch backwards when
⌘
tab
⌃
arrow
- mission control
- application windows — snap aware
- open new via double clicking
- with
⌘
— in a new tab / window - with
⌥
— Open the item in a separate window, then close the original window
- with
- drag app to upper menu bar — mission control
- scroll bar
- click — page up / down
⌥
and click — scroll to
- rectangle (opens new window) app
- virtual desktops
- show launchpad and show desktop
- show launchpad —
⌃
F10
, in System Preferences > Keyboard > Shortcuts > Launchpad & Dock - show desktop — in System Preferences > Mission Control
- show launchpad —
force quit app —
⌥
⌘
esc
boot start
- login items
- plist —
launchctl list
,launchctl unload
- Apple daemons, agents only —
/System/Library/LaunchDaemons
,/System/Library/LaunchAgents
- stop Apple Music from responding to media play button (also affects other apps when using external keyboard)
launchctl unload -w /System/Library/LaunchAgents/com.apple.rcd.plist
- stop Apple Music from responding to media play button (also affects other apps when using external keyboard)
- 3rd party processes —
/Library/LaunchDaemons
- 3rd agents —
/Library/LaunchAgents
,~/Library/LaunchAgents
- obsolete —
/Library/StartupItems
and/System/Library/StartupItems
- Apple daemons, agents only —
- kernal extension (kext) —
/System/Library/Extensions
- cron job —
cron
volume
⌥
⇧
volume
— Adjust the sound volume in smaller steps- also applies to brightness, with
⌃
for external display (if supported) - also applies to keyboard brightness
- also applies to brightness, with
screenshot
- with
⌃
to save to clipboard ⇧
⌘
3
— whole screen⇧
⌘
4
— selection⇧
⌘
5
— general⇧
⌘
6
— touch bar
- with
# Accessibility
- tts
⌥
esc
# Terminal
meta key
zsh
upgrade_oh_my_zsh
cli
open
— opens each file using the default application for that fileopen [-e] [-t] [-f] [-W] [-R] [-n] [-g] [-h] [-s <partial SDK name>][-b <bundle identifier>] [-a <application>] [filenames] [--args arguments]
- open in Finder if directory
-a <application>
— Opens with the specified applicationopen -a Preview file # open in preview
-e
— Opens with TextEdit
defaults
— like registry in Windows- location —
~/Library/Preferences
,/Library/Preferences
- mouse acceleration —
defaults write .GlobalPreferences com.apple.mouse.scaling -1
- hidden files —
defaults write com.apple.finder AppleShowAllFiles -bool true
- power chime —
defaults write com.apple.PowerChime ChimeOnAllHardware -bool false && killall PowerChime
- location —
- ip —
ifconfig
command utilities
say
— text to speechkillall
— kill processes by name (e.g. Finder)pmset
— manipulate power management settingsdisplaysleepnow
sleepnow
caffeinate
— prevent the system from sleeping on behalf of a utility (the assertion releases after the exit of the utility)-t timeout
, in seconds-w pid
-i utility arguments...
-s utility arguments...
— the assertion is valid only when on AC power
chflags
— change file flagshidden
schg
— system immutable flaguchg
— user immutable flag
- launchpad icon number per row and column
defaults write com.apple.dock springboard-columns -int 8; defaults write com.apple.dock springboard-rows -int 7; defaults write com.apple.dock ResetLaunchPad -bool TRUE; killall Dock
clear
- clear to previous mark —
⌘
l
- clear to previous mark —
ports —
netstat -vanp tcp
-a
— show the state of all sockets-n
— Show network addresses as numbers-p
— protocol
# Finder
show hidden files —
command + shift + .
Add selected Finder item to the Dock —
⌃
⇧
⌘
t
Add the selected item to the sidebar —
⌃
⌘
t
move after copy —
⌥
⌘
v
basic operations
- rename —
enter
- open —
⌘
o
- del —
⌘
del
- get info —
⌘
i
- show origin of alias —
⌘
r
- preview —
␣
or⌃
y
- with
⌥
to preview in fullscreen
- with
- new folder —
⇧
⌘
N
- rename —
move around folder tree
⌘
up arrow
- with
⌃
to open in new window
- with
⌘
down arrow
drag
- drag only
- drag with
⌘
— move - drag with
⌥
— copy - drag with
⌥
⌘
— alias
disclose all folder in list view —
⌥
click the disclosure triangleSelect multiple items that are listed together — Click the first item, then press the Shift key and click the last item. All items in between are included in the selection.
View in menu
search — Narrow your search results on Mac - Apple Support (opens new window)
paste image from clipboard — open preview.app, in menu File -> New from Clipboard
# pkg and brew
SHA
openssl dgst -sha256 ./file
shasum -a 256 filename
pkg —
pkgutil
- uninstall
pkgutil --pkgs # list all installed packages pkgutil --files the-package-name.pkg # list installed files pkgutil --pkg-info the-package-name.pkg # check the location cd / # assuming the package is rooted at /... pkgutil --only-files --files the-package-name.pkg | tr '\n' '\0' | xargs -n 1 -0 sudo rm -f pkgutil --only-dirs --files the-package-name.pkg | tail -r | tr '\n' '\0' | xargs -n 1 -0 sudo rmdir sudo pkgutil --forget the-package-name.pkg
- uninstall
Homebrew
brew cask
— apps- overwrite —
brew cask install --force
- overwrite —
brew cleanup
brew tap buo/cask-upgrade
forbrew cu
- install older version
cd
tobrew --repo homebrew/cask
git log ./Casks/visual-studio-code.rb
git checkout b9381533f8c8af449c8cb05103afc8418fcf5e4e
brew cask reinstall visual-studio-code
git switch master
appleID association to app —
/path_to_app/Contents/_MASReceipt
# Chrome
drag text — hold for a while
install extensions of old version
- Crx4Chrome - Download CRX for Chrome Apps & Extensions (opens new window)
- CRX Viewer (opens new window)
- change
update_url
tolocalhost
inmanifest.json
# Other
customize shortcuts
PDF
- PDF to image use ghostscript
gs -dNOPAUSE -sDEVICE=jpeg -r300 -dJPEGQ=100 -dBATCH -sOutputFile=$PDF-%02d.jpg "$PDF.pdf"
- PDF to image use ghostscript