Skip to content

Mac 环境 (M1 + Monterey)

Mac 简介

配置

(如果有其他 Mac 的话用 Time Machine 直接迁移就好)

Time Machine 恢复后的问题

如果网络不正常

  • 刚配好丝丝要重启
  • 到这里看看删掉与 network 相关的文件,重启:
sh
open /Library/Preferences/SystemConfiguration
sh
# 找到这些文件
com.apple.airport.preferences.plist
com.apple.network.eapolclient.configuration.plist
com.apple.wifi.message-tracer.plist
NetworkInterfaces.plist
preferences.plist

如果是恢复到另一台设备

  • 到 Sharing 改电脑名字,重启
  • Chrome 用一个新账户重新同步(不然似乎历史记录会识别为同一台设备)

System Preferences

  • Language & Region:英语、简体中文
  • Sharing:改电脑名字,重启
  • Software Update
  • Keyboard:先把 Key Repeat 和 Delay 调到最快

安装 Additional Tools for Xcode 里的 Network Link Conditioner(给电脑限速用的)

(如果装 NTFS 工具等需要 Reduced Security

dotfiles

sh
.zprofile
.zshrc
.zsh_history
.nrmrc

终端配置

sudo 无需密码:

sh
echo -e "\n$USER ALL=(ALL) NOPASSWD: ALL" | sudo tee -a /etc/sudoers

允许安装运行任意软件:

sh
sudo spctl --global-disable
sudo spctl --status

bin 目录权限(解决 npm global install 问题):

sh
sudo chown -R $USER /usr/local/bin

复制来的 ssh 私钥要调成只读:

sh
sudo chmod 600 <ssh-file-path>

禁止 PressAndHold(需重启)(解决 这个 VS Code 问题):

sh
defaults write -g ApplePressAndHoldEnabled -bool false

更快的按键重复(控制面板的 KeyRepeat 最快才到 2)(需重启):

sh
defaults write -g InitialKeyRepeat -int 15
defaults write -g KeyRepeat -int 1

提高 Time Machine 的速度(重启后失效,可以做一个 function):

sh
sudo sysctl debug.lowpri_throttle_enabled=0

启用 locate 命令并建立索引:

sh
sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.locate.plist

安装基本工具

魔法丝袜之影(略)

sh
export ALL_PROXY='http://127.0.0.1:1080'

安装 Xcode Command Line Tools:

sh
xcode-select --install

安装 Brew

sh
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

(按照提示)激活 brew 命令:

sh
echo 'eval $(/opt/homebrew/bin/brew shellenv)' >> $HOME/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"

安装一些基本工具(虽然系统自带一些,但是用 brew 来做后续更新):

sh
brew install --formula bat git n scc tig trash tree zsh
brew install --cask google-chrome visual-studio-code iterm2

安装 Oh My Zsh

sh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

安装 更纱黑体"Sarasa Mono SC", "Sarasa Term SC"):

sh
brew tap homebrew/cask-fonts
brew install font-sarasa-gothic

安装 Node.js(我用 n 来管理):

sh
sudo n 16

Finder

  • 显示扩展名:cmd + , > Advanced
  • (剪切功能的快捷键:cmd + option + v

总是显示隐藏文件:

sh
defaults write com.apple.finder AppleShowAllFiles -boolean true; killall Finder

标题显示完整路径:

sh
defaults write com.apple.finder \_FXShowPosixPathInTitle -bool true; killall Finder

Open In Terminal,(装好到 System Preferences > Extensions 开启):

sh
brew install openinterminal

(其他配置略,cmd + ,cmd + j

其他安装的工具

npm global

npm -g i

  • pnpm:代替 npm 用
  • @antfu/ni:自动判断当前的包管理器(npm、yarn、pnpm)
  • @types/node:node 的类型定义,写 ts 脚本的时候辅助用
  • serve:读本地文件夹起一个 server(类似 http-server)
  • tldr:简化的 help 工具(类似 man 或 --help)
  • tsno:更方便的 ts-node 的代替品,底层是 esbuild
  • vercel:部署本地 app dist 到 vercel

把全局安装的 @types 软链接到根目录,以便 ts 全局搜索

sh
mkdir -p ~/node_modules/
ln -s ~/pnpm-global/5/node_modules/@types ~/node_modules/@types

brew

brew install

  • bat:显示文件内容(类似 cat)
  • n:Node 版本管理器
  • neofetch:显示当前环境信息(类似 screenfetch)
  • pngquant:png 图片压缩
  • scc:统计代码行数(类似 cloc)
  • smartmontools:磁盘健康度
  • tig:更方便的 git history
  • trash:扔到垃圾桶(用来代替 rm -rf
  • tree:显示文件夹树状结构
  • you-get:视频下载器

brew cask

brew install --cask

App store

Layout Switch

Adjust the layout style of VitePress to adapt to different reading needs and screens.

Expand all
The sidebar and content area occupy the entire width of the screen.
Expand sidebar with adjustable values
Expand sidebar width and add a new slider for user to choose and customize their desired width of the maximum width of sidebar can go, but the content area width will remain the same.
Expand all with adjustable values
Expand sidebar width and add a new slider for user to choose and customize their desired width of the maximum width of sidebar can go, but the content area width will remain the same.
Original width
The original layout width of VitePress

Page Layout Max Width

Adjust the exact value of the page width of VitePress layout to adapt to different reading needs and screens.

Adjust the maximum width of the page layout
A ranged slider for user to choose and customize their desired width of the maximum width of the page layout can go.

Content Layout Max Width

Adjust the exact value of the document content width of VitePress layout to adapt to different reading needs and screens.

Adjust the maximum width of the content layout
A ranged slider for user to choose and customize their desired width of the maximum width of the content layout can go.

Spotlight

Highlight the line where the mouse is currently hovering in the content to optimize for users who may have reading and focusing difficulties.

ONOn
Turn on Spotlight.
OFFOff
Turn off Spotlight.