💬 过几年换电脑就做一次,由于上一份工作不常用 Mac,需要安装一系列的东东,还挺折腾的,所以记录一下。
MBP,iMac,iPhone,已经很普遍了,不像 10~20 年前,那是高大上的东西,现在网上各种相关资料很多。
几大块,顺序不重要。工具和软件很多,把基本的先搞定。
键盘 & 鼠标
不得不吐槽,Apple 家的我极不习惯(用过至少两代了),键盘换成了 K1 Bluetooth:
low profile,无线,低噪声,原生 Mac 布键(可以切换至 Windows),18 种酷炫夜光模式
鼠标换成了 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:
其它
✦ Disable System Integrity Protection (SIP)
需要重启 Mac 进入 Recovery 模式(开机时同时按下 ⌘R)
$ csrutil disable
$ reboot
重启后查看 SIP:
$ csrutil status
System Integrity Protection status: disabled
✦ Disable Gatekeeper
sudo spctl --master-disable
✦ 显示隐藏文件
希望在 Finder 里看到这个目录的内容
$ chflags nohidden ~/Library
$ defaults write com.apple.finder AppleShowAllFiles -bool TRUE
$ defaults write com.apple.finder _FXShowPosixPathInTitle -boolean 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: ⌃⌘Space (弹出 emojis)
- 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,⌘↑,⌘↓
- 回到前一个目录: ⌘[
- 转到下一个目录: ⌘]
- 隐藏文件的开关: ⇧⌘.
软件
必备工具
- Amphetamine:防止进入睡眠状态,定时休眠
- Cheatsheet:当前程序的快捷键清单,默认的快捷键是长按 ⌘
- CleanMyMac:垃圾清理,软件卸载
- f.lux:调色
- Keka:相当于 WinRAR,WinZIP
- Moom:管理 Window 的大小和位置,超级好用,配上快捷键
- Paralles Desktop:Windows 虚拟机
- PopClip:copy & paste
- SnagIt:截屏、 编辑
- TotalFinder:Finder 加强版,Finder 和 Explorer 是操作系统里最重要的软件
✦ 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 回收站
✦ Aflred 据说是个神器,稍后有时间才研究。
✦ Apple 会把 TNT 的证书删除,碰到软件打不开的问题,需要自行重新签发证书:
> codesign --force --deep --sign - /Applications/xxx.app
常用软件
网上都有盗版或破解,需要花点时间找。Apple 的 MacOS 源自 Unix,但其自带系统软件难用,一二十年毫无大进步,和微软的 Windows 的用户体验差距不小,好在是第三方挺给力。
- Adobe Reader
- Chrome
- Clearview:各种电子书(epub,chm,等常用格式)阅读器
- Movist Pro:Mac 上最好的 movie 播放器 👍🏻
- Reeder:rss 订阅
- ScreenFlow:录屏
- Windows Office for Mac
- Dash
- 各种网盘软件:百度网盘、Dropbox、Google Drive 等
- 微信,电报,推特等社交软件
开发工具
JetBrain 的全家桶(IntelliJ
,Pycharm
,WebStorm
,Goland
)是我十多年来开发 Java 和其它语种的主力 IDE,各种文本编辑基本已归置 VS Code
和 强大的 Notepad++
(Windows only)。
vi/vim 我是半吊子,非常有空才打算深入。
IntelliJ
✦ 配置参考:
✦ 快捷键参考:
参考 IntelliJ 功夫
Pycharm
参考 Pycharm 功夫
Visual Studio Code
装一堆插件/扩展,用 Settings Sync 管理很方便。 配置 & 快捷键,参考 VS Code 功夫
Git
参考 Git 功夫
Chrome
Chrome 的配置和插件用 Google Sync 来管理很方便,参考 Chrome 功夫
命令行
💡 命令行各种配置的保留,参考之前的文章: 如何保存 dotfiles
命令行的东西比较杂,主要有那么几大件:
- Homebrew:软件安装管理必备神器,相当于 Linux 上的 yum,装完后一通 brew cask install 和 brew install
- zsh & oh-my-zsh(OMZ):OMZ 是个 zsh 的集成者
- iTerm2:比 Mac 自带的 terminal 强,颜色(Dracula),字体(Hack),窗体,快键唤出等等,自行安装和设置。另外可以配合 tmux 多窗口管理器使用。
brew
[I] ➜ brew list
asciinema kmdr protobuf
autoconf kubectx psgrep
autojump kubernetes-cli pstree
aws-session-manager-plugin lazygit pyenv
awscli libevent python
bat libidn2 python@3.8
cheat libmpc rbenv
cmatrix libunistring readline
curl libyaml ripgrep
diff-so-fancy libzip ruby
exa lua ruby-build
fd maven rustup-init
fzf minikube shellcheck
gcc mpfr sqlite
gdbm ncdu ssm-helpers
gettext ncurses the_silver_searcher
git netcat thefuck
glances nmap tig
gmp node tldr
go oniguruma tree
gradle openjdk utf8proc
highlight openssl vim
htop openssl@1.1 wget
httpie pcre xz
hub pcre2 zsh
hugo perl zsh-autosuggestions
icu4c pipenv zsh-completions
isl pkg-config zsh-history-substring-search
jq poetry zsh-syntax-highlighting
k9s prettyping
有许多增强型命令行工具,并善用命令行的 alias,例如:
- ag/ripgrep:取代 grep
- asciinema:可以录制 terminal
- bat:取代 cat
- exa:取代 ls
- fd:取代 find
- fzf:文件模糊搜索,参考 Vim universe. fzf - command line fuzzy finder
- htop:取代 top
- httpie:命令行 http,类似 wget,curl
- jq:json 文件浏览、格式化、支持高亮
- psgrep
- pstree
- shellcheck:shell script 语法检查
- thefuck
- tig
- tldr:取代 man
- 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:
命令行提示符
OMZ Theme 自带的和那个 Powerlevel10K 太眼花缭乱,这个简约 spaceship
alias
### brew
alias b="brew"
### clear
alias c="clear"
alias cat="bat"
### vs code
alias codegit="code ~/.gitconfig"
alias codeignore="code ~/.gitignore"
alias codessh="code ~/.ssh/config"
alias codevim="code ~/.vimrc"
alias codezsh="code ~/.zshrc"
### docker
alias d="dock"
alias diff="colordiff"
### Find
alias f="fd"
alias fuck="thefuck"
alias egrep="egrep --color=aut-exclude-dir={.bzr,CVS,.git,.hg.svn }"
alias fgrep="fgrep --color=auto --exclude-dir={.bzr,CVS,.git,.hg.svn }"
### git
alias g="git"
alias help="tldr"
### istio
alias i="istioctl"
### kubernetes
alias k="kubectl"
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'
### npm
alias n='npm'
### quit
alias q="exit"
alias rd="rmdir"
### ssh
alias s="ssh"
alias top="htop"
alias xcode="open -a '/Applications/XCode.app'"
alias zsh="source ~/.zshrc"
alias _=sudo
alias -g G="| grep"
alias -g L="| less"
iTerm2
shell 集成
iTerm2 -> Install Shell Integration
快速唤出命令行窗口
创建一个新的 Profile:
配置完,按 F12 可以随时唤出 iTerm2 悬浮窗口,再按消失。
iTerm2 技巧
- iTerm2 允许我们快速查看剪贴板内容 只需使用 Command + Shift + h 可以呼出粘贴历史
- 在 iTerm2 中,双击选中,三击选中整行,四击智能选中(智能规则可配置)
- 按住 ⌘ 键:可以拖拽选中的字符串
- 点击 url:调用默认浏览器访问该网址;
- 点击文件:调用默认程序打开文件;
- 点击文件夹:在 finder 中打开该文件夹;
- 同时按住 option 键,可以以矩形选中,类似于 vim 中的 ctrl v 操作
- 将文本内容复制到剪切板
- 在 Finder 中打开当前目录
命令行快捷键 & 技巧
把 bindkey -v
加到 .zshrc 里,命令行就可以用 vi 的快捷键( bindkey -e
则是 emacs)。
command + t 新建标签 command + w 关闭标签 command + 数字 command + 左右方向键 切换标签 command + enter 切换全屏 command + f 查找 command + d 水平分屏 command + shift + d 垂直分屏 command + option + 方向键 command + [ 或 command + ] 切换屏幕 command + ; 查看历史命令 command + shift + h 查看剪贴板历史 ctrl + u 清除当前行 ctrl + l 清屏 ctrl + a 到行首 ctrl + e 到行尾 ctrl + f/b 前进后退 ctrl + p 上一条命令 ctrl + r 搜索命令历史
巨量资源
- MacRumors Buyer’s Guide
- Mac OS X 配置指南
- macOS development environment setup
- macOS Setup Guide
- awesome-mac 软件大集合
- awesome cli apps:A curated list of command line apps
- awesome shell:A curated list of awesome command-line frameworks,toolkits,guides and gizmos
- ✨Mac 软件合集,低调使用