过几年换电脑就做一次,由于上一份工作不常用 Mac,需要安装一系列的东东,还挺折腾的,所以记录一下。
💬 MBP,iMac,iPhone,已经很普遍了,不像 10~20 年前,那是高大上的东西,现在网上各种相关资料很多。几大块,顺序不重要。工具和软件很多,把基本的先搞定。
键盘 & 鼠标
不得不吐槽,Apple 家的我极不习惯(用过至少两代了),键盘换成了 K1 Bluetooth :low profile,无线,低噪声,原生 Mac 布键(可以切换至 Windows),18 种酷炫夜光模式
2020 更新:K1 价廉物美,就是不耐操,疫情在家一年下来,电池很快掉电,键盘不灵敏了,几个常用键需要大力敲几次,MX Keys 已经替换上场:

鼠标换成了 Logi MX Master3 :



Mac 上的好鼠标太少,此前的用过两个雷神的 DeathAdder,基本寿命就是两年,手感,响应准确度等均弱于 MX Master3
以上两个东西性价比极好,网评可以看一波,至今我超级满意 👍🏻。
✦ 题外话:电脑座椅也相当重要,值得投入。
MacOS 基本配置
System Preference
✦ Keyboard
功能键 Fn:默认情况下,F1-F12 都是特殊功能,比如调节屏幕亮度。而当你需要键入 F1-F12 时需要同时按住 Fn,这对于开发人员来说是非常不方便的。将 F1-F12 改成标准功能键。
键盘控制:上图里选 Shortcuts,然后 ☑️User keyboard navigation to move focus between controls
Caps 切换输入法

✦ Dock

Finder
Finder -> Preference -> Advanced:

Finder -> View -> Show View Options:

其它
✦ macOS 默认只允许运行通过苹果应用商店下载的软件。macOS 如果想安装第三方应用需要到 Preference/系统偏好设置 > Security & Privacy/安全性与隐私 > General/通用 中开启,Allow apps downloaded from: 🔘 Anywhere
✦ Disable System Integrity Protection (SIP)
需要重启 Mac 进入 Recovery 模式(开机时同时按下 ⌘ r)
$ csrutil disable
$ reboot
重启后查看 SIP:
$ csrutil status
System Integrity Protection status: disabled
✦ Disable Gatekeeper
macOS 如果想安装第三方未签名的应用需要在终端中执行命令行:
sudo spctl --master-disable
✦ 显示隐藏文件
希望在 Finder 里看到这个目录的内容
# show Library folder
chflags nohidden ~/Library
# show hidden files
defaults write com.apple.finder AppleShowAllFiles YES
# show path bar
defaults write com.apple.finder ShowPathbar -bool true
# show status bar
defaults write com.apple.finder ShowStatusBar -bool true
$ defaults write com.apple.finder _FXShowPosixPathInTitle true
$ killall Finder
✦ screenshot
默认情况下,macOS Mojave 将屏幕截图存储在 Mac 的桌面上。现在,如果您启用了 iCloud 同步,那么它会不断上传到您的帐户。这是不安全的,也很占空间。
$ defaults write com.apple.screencapture location ~/Downloads
$ defaults write com.apple.screencapture type PNG
$ killall SystemUIServer
每次截图自带阴影效果,可以关闭或开启:
关闭
$ defaults write com.apple.screencapture disable-shadow -bool true; killall SystemUIServer
开启
$ defaults write com.apple.screencapture disable-shadow -bool false; killall SystemUIServer
其它很多设置,根据自己的喜好可以网上参考一番。
✦ iTune/Music.app
Account -> Authorizations -> Authorize This Computer
MacOS 常用快捷键
众人皆知/常用:⌘ A ⌘ C ⌘ V ⌘ X ⌘ Z ⌘ F ⌘ N ⌘ Tab ⌘ Space ⌘ W ⌘ Q
系统通用
- 强行退出: ⌥ ⌘ Esc
- 锁屏: ⌃ ⌘ Q
- 进入全屏模式:⌃ ⌘ F
- Character Viewer(弹出 emojis): ⌃ ⌘ Space
- Show all windows of the front app: ⌃ ↓
- Show all windows: ⌃ ↑
- Forward delete: Fn del
- Paste without formatting: ⇧ ⌘ V
- Screenshot: ⇧ ⌘ 4 ⇧ ⌘ 3
Finder
- 打开 home folder: ⇧ ⌘ H
- 打开 desktop folder: ⇧ ⌘ D
- 打开文件、上级目录、下级目录:⌘O ⌘↑ ⌘↓
- 回到前一个目录: ⌘ [
- 转到下一个目录: ⌘ ]
- 隐藏文件的开关: ⇧ ⌘ .
软件
网上都有盗版或破解,需要花点时间找。Apple 的 MacOS 源自 Unix,但其自带系统软件难用,一二十年毫无大进步,和微软的 Windows 的用户体验差距不小,好在是第三方挺给力。
必备工具
- Amphetamine:防止进入睡眠状态,定时休眠
- App Cleaner & Unistaller:应用深度清理卸载
- f.lux:调色
- Hidden Bar:菜单栏图标隐藏
- KeyCue:列出了当前活动应用所有支持的键盘快捷组合键
- Lemon:垃圾清理,软件卸载,毙掉
CleanMyMac
(大伙反映是款流氓软件) - Mouseless:应用快捷键查看及记忆
- MacZip:压缩/解压缩
- Moom:管理 Window 的大小和位置,超级好用,配上快捷键
- Paralles Desktop:Windows 虚拟机,配合 PD Runner(原来挂在 Github 上,后来被毙了,可到 Gitee 上下载),解锁最新试用版 Paralles
- Rectangle:开源版的 spectacle,和 Moom 类似管理窗口大小和定位,拖拽窗口即能定位
- TotalFinder、Path Finder、Default Folder X、iRightMousse Pro:Finder 加强版工具,Finder 和 Windows Explorer 一样是操作系统里最常用和最重要的软件
- iTerms2、zsh、oh-my-zsh:命令行相关,见下
一些体会:
- List of useful Quick Look plugins for developers
- USB 外挂大硬盘必备,读写 NTFS,发现 Paragon NTFS 或者 Tuexra NTF,移动文件过程中会出现文件莫名其妙的失踪 🥶,只好采取虚机这个迂回的办法。
- Paralles:Windows 对 MBP 的 Retina 的支持不好,DPI 不可以超过 185%,参见 Resize Search Box and Address Box Win7
- Paralles:在 Windows 里删除 shared folder 里的文件(非挂靠在 Windows 的硬盘),不会进入 Windows 回收站
- Moom 的快捷窗口操作:
- Aflred 据说是个神器,稍后有时间才研究。
- Apple 会把 TNT 的证书删除,碰到软件打不开的问题,需要自行重新签发证书:
> codesign --force --deep --sign - /Applications/xxx.app
常用软件
- Adobe Acrobat:PDF 老东家,还是比 PDF Expert 好用
- Aerial Companion:精致的屏保
- Beyond Compare:文件对比比较神器
- Boom3D:音效加强
- NeatReader:各种电子书(epub,chm,等常用格式)阅读器
- Dash:编程文档
- Downie:各种视频下载,支持优酷、腾讯视频、bilibili、土豆、爱奇艺、网易、搜狐、微博以及国外的 Youtube 等等
- Find My:跟踪 Apple 设备,防止遗失
- Folx Pro:各种 p2p 下载
- GoodNote:手写体笔记
- magnetw:开源种子搜索神器 👍🏻
- Movist Pro:Mac 上最好的 movie 播放器 👍🏻
- Reeder:rss 订阅
- Renamer:文件批量重命名
- ScreenFlow:录屏 👍🏻
- Sketch:矢量画图
- Typora MarkText:所见即所得的 markdown 编辑器
- XMind:思维导图
其它常用软件:
- Chrome 及一堆插件(Goolge 同步)
- Windows Office for Mac
- 各种网盘软件:百度网盘、Dropbox、Google Drive 等
- 微信 Wechat,Whatsapp,Telegram,Twitter,Discord,Slack,Zoom,Teams 等一众社交软件
开发工具
JetBrain 的全家桶 IntelliJ Pycharm WebStorm Goland 是我十多年来开发 Java 和其它语种的主力 IDE,各种文本编辑基本已归置 VS Code 和 强大的 Notepad++(Windows only)。Windows 上经常画图的工具是Visio,慢慢转到 Excalidraw 和 draw.io。
vi/vim 我是半吊子,非常有空才打算深入。
VPN
🆓 七款 VPN 比较:
VPN 名称 | 注册 | 可连接国家 | 限速 | 用量 | 使用设备 | 广告 | P2P |
---|---|---|---|---|---|---|---|
AtlasVPN | 不要 ✅ | 3 | 🈶️ | 无限制 ✅ | 1 | 🈚️ ✅ | 是 ✅ |
Hotspot Shield | 不要 ✅ | 1 | 🈶️ | 500MB/天 | 1 | 🈶️ | 是 ✅ |
PrivadoVPN | 要 | 12 | 🈚️ ✅ | 10GB/月 | 1 | 🈚️ ✅ | 是 ✅ |
ProtonVPN | 要 | 3 | 🈶️ | 无限制 ✅ | 1 | 🈚️ ✅ | 否 |
Speedify | 不要 ✅ | 几乎全部 ✅ | 🈚️ ✅ | 1GB/月 | 1 | 🈚️ ✅ | 否 |
TunnelBear | 要 | 23 | 🈚️ ✅ | 500MB/天 | 1 | 🈚️ ✅ | 是 ✅ |
Windscribe | 要 | 10 | 🈶️ | 10GB/月 | 1 | 🈚️ ✅ | 否 |
命令行
💡 命令行各种配置的保留,参考之前的文章: 如何保存 dotfiles
命令行的东西比较杂,主要有那么几大件:
- homebrew:软件安装管理必备神器,相当于 Linux 上的 yum,装完后一通 brew cask install 和 brew install
- zsh oh-my-zsh(OMZ):OMZ 是个 zsh 的集成者
- iTerm2:比 Mac 自带的 terminal 强,颜色(Dracula),字体(Hack),窗体,快键唤出等等,自行安装和设置。另外可以配合 tmux 多窗口管理器使用。
brew
brew 的备份和迁移
brew 可以通过 brew bundle 进行备份,然后一键在另外一台机器上恢复:
备份 Brewfile:
[I] ➜ alias bdump="rm ~/Brewfile; brew bundle dump; dotadd ~/Brewfile; dotcmt ~/Brewfile; dotpush"
[I] ➜ bdump
[I] ➜ cat ~/Brewfile
───────┬────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ File: Brewfile
───────┼────────────────────────────────────────────────────────────────────────────────────────────────────────────────
1 │ tap "adoptopenjdk/openjdk"
2 │ tap "derailed/k9s"
3 │ tap "disneystreaming/tap"
4 │ tap "gapple/services"
5 │ tap "homebrew/bundle"
6 │ tap "homebrew/cask"
7 │ tap "homebrew/cask-fonts"
8 │ tap "homebrew/cask-versions"
9 │ tap "homebrew/core"
10 │ tap "homebrew/services"
11 │ tap "kommandr/tap"
12 │ brew "gdbm"
13 │ brew "openssl@1.1"
14 │ brew "readline"
15 │ brew "sqlite"
16 │ brew "xz"
17 │ brew "asciinema"
18 │ brew "autojump"
19 │ brew "bat"
20 │ brew "broot"
21 │ brew "cheat"
22 │ brew "cmatrix"
23 │ brew "colordiff"
24 │ brew "ctop"
Brewfile 和通常的 brew 略有不同:
命令行 | Brewfile |
---|---|
brew install [formulaName] | brew “[forumlaName]” |
brew cask install [caskName] | cask “[caskName]” |
mas install [identifier] | mas “[bundleIdentifier]", id: [identifier] |
恢复/安装:
$ brew bundle
各种有用的工具
有许多增强型命令行工具,并善用命令行的 alias,例如:
- ag:搜索工具,类似 ack,但更快

- asciinema:可以录制 terminal

- bat:增加语法高亮,取代 cat

- broot:取代 tree

- choose:cut 和 awk 功能结合

- curlie: 简化 curl

- dust:Rust 开发,取代 du

- exa:取代 ls

- fd:取代 find
- fig:命令行自动补全

- fzf:文件模糊搜索,参考 Vim universe. fzf - command line fuzzy finder

- gping:取代 ping

- hyperfine:benchmark/测速工具

htop:取代 top 类似的还有gtop
httpie:命令行 http,类似 wget,curl

- jq:json 文件浏览、格式化、支持高亮

- procs:取代 ps,用 Rust 开发

psgrep:取代 ps aux | grep
pstree:Linux 上移植过来,树型方式显示进程
ripgrep:和 grep 类似但遵循 gitignore

- sd:取代 sed

- shellcheck:shell script 语法检查

- thefuck:神器

- tldr:取代 man
- xh:与 httpie 简洁界面类似,但速度更快

- xz:压缩工具
zsh
plugins
plugins=(
alias-finder
ansible
brew
docker
docker-compose
extract
git
golang
grunt
gulp
helm
kubectl
mvn
node
npm
pip
postgres
python
spring
timer
vagrant
)
zsh 的插件很多,自行选择 awesome-zsh-plugins :
- zsh-syntax-highlighting

- zsh-autosuggestions

- zsh-history-substring-search

命令行提示符
OMZ Theme 自带的和那个 Powerlevel10K 太眼花缭乱,这个简约 spaceship
alias
### =======
### Alias
### =======
# ansible
alias a="ansible"
# brew
alias b="brew"
alias brewdump="rm ~/Brewfile; brew bundle dump; dotadd ~/Brewfile; dotcmt ~/Brewfile; dotpush"
alias brewsearch="brew search"
alias brewinfo="brew info"
alias brewadd="brew install"
alias brewdel="brew uninstall"
alias brewlist="brew list --versions"
alias brewupdate='echo "updating brew formulas and casks ....."; brew update; brew outdated --verbose; brew upgrade; brew cleanup --prune=all; brew doctor --verbose; brew outdated --cask --verbose; brew upgrade --cask; brew doctor --verbose'
alias c="bat"
alias cdls='f_cdls(){cd "$1" && exa}; f_cdls'
alias cddown="cd ~/Downloads; exa"
alias cdwork="cd ~/workspace; exa"
alias cdmy="cd /Volumes/MySpace2021/; exa"
# vs code
alias codegit="code ~/.gitconfig"
alias codeignore="code ~/.gitignore"
alias codessh="code ~/.ssh/config"
alias codevim="code ~/.vimrc"
alias codezsh="code ~/.zshrc"
alias codeblog="code /Users/zhonglun/workspace/blog/blog.code-workspace"
# mac dot
alias dot='/usr/bin/git --git-dir=$HOME/.mdot/ --work-tree=$HOME'
alias dotadd='/usr/bin/git --git-dir=$HOME/.mdot/ --work-tree=$HOME add '
alias dotcmt='/usr/bin/git --git-dir=$HOME/.mdot/ --work-tree=$HOME commit -m "dotcmt" '
alias dotpush='/usr/bin/git --git-dir=$HOME/.mdot/ --work-tree=$HOME push -u origin master'
alias dotstat='/usr/bin/git --git-dir=$HOME/.mdot/ --work-tree=$HOME status'
alias df="df -ahP | column -t"
alias diff="colordiff"
alias du="du -shx */ | sort -h"
alias e="echo"
alias f="find"
alias finder="open -a Finder"
alias egrep="egrep --color=auto --exclude-dir={.bzr,CVS,.git,.hg.svn }"
alias fgrep="fgrep --color=auto --exclude-dir={.bzr,CVS,.git,.hg.svn }"
# git
alias g="git"
alias gitconfig="nocorrect git config --list"
alias gitadd="git add ."
alias gitbra="git branch"
alias gitco="git checkout -b"
alias gitcod="git checkout develop"
alias gitcom="git checkout main"
alias gitcmt="git commit -v"
alias gitdf="git diff --cached"
alias gitlog="git log --online --decorate --graph"
alias gitpull="git fetch && git merge"
alias gitpush="git push"
alias gitstat="git status"
alias gitundo="git reset 'HEAD@{1}'"
alias gover="go version"
alias gemupdate='echo "updating ruby gems ....."; sudo gem update --system && gem cleanup'
alias h="history | grep"
alias help="tldr"
# hugo blog
alias hg="cd /Users/zhonglun/workspace/blog/web/fastzhong-hugo; hugo server -D -p 1616"
alias hgcd="cd /Users/zhonglun/workspace/blog/web/fastzhong-hugo"
alias hgpush="cd /Users/zhonglun/workspace/blog/web/fastzhong-hugo && git add . && git commit -a -m 'hugo blog' && git push && cd -"
# java
alias j="java"
alias javaver="java -version"
# kubernetes
alias k="kubectl"
alias kbcfg="nocorrect kubectl config view"
alias kbctx="kubectx"
alias kbns="kubens"
alias kbx="kubectl explain"
alias k9="kill -9"
alias k15="kill -s 15"
# ls
alias l="exa -lhF"
alias ll="exa -lahF"
alias ls="exa -ah"
alias listen='lsof -PiTCP -sTCP:LISTEN'
alias mkcd='f_mkcd(){mkdir -pv "$1"; cd "$1"}; f_mkcd'
alias mnt="mount | column -t"
alias netroute="netstat -nr"
alias netlisten="netstat -n -a -p tcp | grep LISTEN"
# npm
alias n="npm"
alias nodever='echo "Node version: $(node -v)"; echo "NPM version: $(npm -v)"'
alias npmcfg='nocorrect npm config ls -l'
alias npminit="npm init"
alias npmadd="npm install"
alias npmaddg="npm install -g"
alias npmsave="npm install --save"
alias npmdev="npm install --save-dev"
alias npmrun="npm run"
alias npmdel="npm uninstall"
alias npmdelg="npm uninstall -g"
alias npmupdate='echo "updating node global modules ......"; npm cache verify; npm outdated -g; npm update -g; npm audit fix; npm fund'
alias ping="prettyping --nolegend"
# python
alias py="python"
alias pyver='echo "Python versions: "; echo "$(pyenv versions)"'
alias pyupdate='echo "updating all python packages ....."; sudo pip install -U pip && pip freeze --local | grep -v "^\-e" | cut -d = -f 1 | xargs pip install -U; rm ~/.pip/cache/*'
alias q="exit"
alias rg="ripgrep"
### ssh
alias s="ssh"
alias sshls="grep 'Host ' ~/.ssh/config | awk '{print $2}' | sort -h"
### terraform
alias tf="terraform"
alias top="htop"
alias v="vite"
alias vg="vagrant"
alias x="open -a '/Applications/XCode.app'"
alias y="yarn"
alias z="source ~/.zshrc"
alias _=sudo
alias -g G="| grep"
alias -g L="| less"
shell 集成
iTerm2 -> Install Shell Integration
selection

快速唤出命令行窗口
创建一个新的 Profile:


配置完,按 F12 可以随时唤出 iTerm2 悬浮窗口,再按消失。
iTerm2 技巧
- iTerm2 允许我们快速查看剪贴板内容 只需使用 ⌘ ⇧ h 可以呼出粘贴历史
- 在 iTerm2 中,双击选中,三击选中整行,四击智能选中(智能规则可配置)
- 按住 ⌘ 键:可以拖拽选中的字符串
- 点击 url:调用默认浏览器访问该网址;
- 点击文件:调用默认程序打开文件;
- 点击文件夹:在 finder 中打开该文件夹;
- 同时按住 ⌥ 键,可以以矩形选中,类似于 vim 中的 ⌃ v 操作
- 将文本内容复制到剪切板
- 在 Finder 中打开当前目录
命令行快捷键 & 技巧
vi
把 bindkey -v 加到 .zshrc 里,命令行就可以用 vi 的快捷键(bindkey -e 则是 emacs)。
Tabs and Windows
Function | Shortcut |
---|---|
New Tab | ⌘ + T |
Close Tab or Window | ⌘ + W (same as many mac apps) |
Go to Tab | ⌘ + Number Key (ie: ⌘2 is 2nd tab) |
Go to Split Pane by Direction | ⌘ + Option + Arrow Key |
Cycle iTerm Windows | ⌘ + backtick (true of all mac apps and works with desktops/mission control) |
Splitting | |
Split Window Vertically (same profile) | ⌘ + D |
Split Window Horizontally (same profile) | ⌘ + Shift + D (mnemonic: shift is a wide horizontal key) |
Moving | |
Move a pane with the mouse | ⌘ + Alt + Shift and then drag the pane from anywhere |
Fullscreen | |
Fullscreen | ⌘ + Enter |
Maximize a pane | ⌘ + Shift + Enter (use with fullscreen to temp fullscreen a pane!) |
Resize Pane | Ctrl + ⌘ + Arrow (given you haven’t mapped this to something else) |
Less Often Used By Me | |
Go to Split Pane by Order of Use | ⌘ + ] , ⌘ + [ |
Split Window Horizontally (new profile) | Option + ⌘ + H |
Split Window Vertically (new profile) | Option + ⌘ + V |
Previous Tab | ⌘ + Left Arrow (I usually move by tab number) |
Next Tab | ⌘ + Right Arrow |
Go to Window | ⌘ + Option + Number |
快速移动
Function | Shortcut |
---|---|
Move to the start of line | Ctrl + A or Home |
Move to the end of line | Ctrl + E or End |
Move forward a word | Option + F |
Move backward a word | Option + B |
Set Mark | ⌘ + M |
Jump to Mark | ⌘ + J |
Moving by word on a line (this is a shell thing but passes through fine) | Ctrl + Left/Right Arrow |
Cursor Jump with Mouse (shell and vim - might depend on config) | Option + Left Click |
Copy & Paste
Function | Shortcut |
---|---|
Enter Copy Mode | Shift + ⌘ + C |
Enter Character Selection Mode in Copy Mode | Ctrl + V |
Move cursor in Copy Mode | HJKL vim motions or arrow keys |
Copy text in Copy Mode | Ctrl + K |
命令行历史
Function | Shortcut |
---|---|
Search as you type | Ctrl + R and type the search term; Repeat Ctrl + R to loop through result |
Search the last remembered search term | Ctrl + R twice |
End the search at current history entry | Ctrl + Y |
Cancel the search and restore original line | Ctrl + G |
常用
Function | Shortcut | Use |
---|---|---|
Delete to start of line | Ctrl + U | Use this to start over typing without hitting Ctrl-C |
Delete to end of line | Ctrl + K | Use this with command history to repeat commands and changing one thing at the end! |
Repeat last command | Up Arrow | Cycle and browse your history with up and down. Ctrl-R is faster if you know the string you are looking for. |
Move back and forth on a line | Arrow Keys | This takes you off the home row but it’s easy to remember |
Move back and forth on a line by words | ⌥ + Arrow Keys | Fast way to jump to a word to correct a typo or “run again” with minor changes |
Delete previous word (in shell) | Ctrl + W | It’s faster to delete by words. Especially when your last command was wrong by a single typo or something. |
Clear screen | Ctrl + L | This is telling the shell to do it instead of an explicit command like clear or cls in DOS. If you use ⌘ + K , this is telling iTerm to clear the screen which might have the same result or do something terrible (like when using a TUI like top or htop . In general, use this instead of typing clear over and over. |
巨量资源
🛒 购买 MacRumors Buyer’s Guide :非常实用,购买苹果产品前必看 💎💎💎
🛒 命令行
- awesome cli apps :A curated list of command line apps
- awesome shell :A curated list of awesome command-line frameworks,toolkits,guides and gizmos
- awesome-macos-command-line :收集了很多有趣的 Mac 终端命令
🛒 软件介绍
- 零度解说 :各种免费资源,开车资源
- awesome-mac 软件大集合 :收集各种类别非常好用的 Mac 应用程序、软件以及工具
🛒 软件下载
- MacWk.com 精品 Mac 应用 :低调使用 💎💎💎