mac初始化配置
必装软件
- TotalFinder
- Alfred
- Maven
- Git
- Protobuf
- SourceTree
- IntelliJ IDEA
- Docker
- ClashX
- PlistEdit Pro
- HomeBrew
- XMind
- Gliffy Diagrams
- Sublime
- 空气日历
- iShot
- Timeout
- PicGo 图床软件, Blog必备
HomeBrew安装配置
安装脚本
/bin/bash -c "$(curl -fsSL https://cdn.jsdelivr.net/gh/ineo6/homebrew-install/install.sh)"修改源站
中文安装教程(建议收藏):https://brew.idayer.com/
如果你想换源,可以使用镜像助手:https://brew.idayer.com/guide/change-source/
必要配置
关闭SIP安全设置
1、重启 Mac,按住 Command+R 键直到 Apple logo 出现,进入 Recovery Mode
2、点击 Utilities > Terminal。(我的是中文版的,看图左上角,实用工具 > 终端)
3、在 Terminal 中输入 csrutil disable,之后回车
4、重启 Mac
(这样 SIP 安全设置就已经被关闭了,如果想重新开启该安全设置,重复上面步骤,在第三步中将命令更换为 csrutil enable。)
删除默认英文输入法
- 关闭SIP
- 使用PlistEdit Pro 编辑 ~/Library/Preferences/com.apple.HIToolbox.plist
- 删除 ABC的选项(或者U.S): ![]() 
- 再次重启电脑
参照
使用bash, 替换掉默认的zsh
全局账号
iterm
iTerm2->Preferences->Profiles->Command
去除掉zsh烦人的提示
提示
The default interactive shell is now zsh.
To update your account to use zsh, please run `chsh -s /bin/zsh`.
For more details, please visit https://support.apple.com/kb/HT208050.解决方案
> ~/.bash_profile
export BASH_SILENCE_DEPRECATION_WARNING=1参见
Suppressing “The default interactive shell is now zsh” message in macOS Catalina
开启触摸板轻点确认
经常需要在触摸板上点击之类的, 默认是需要按下去, 才算是点击按钮, 但这样太费劲儿.
开启tab切换对话框选项
其他配置
github连接不上
fatal: unable to access 'https://github.com/DavyJones2010/davyjones2010.github.io.git/': Failed to connect to github.com port 443: Operation timed out或者
SSL_ERROR_SYSCALL in connection to github.com:443根本原因是本地启用了VPN(ClashX), 使用如下命令配置git的proxy即可:
git config --global http.proxy 127.0.0.1:7890
git config --global https.proxy 127.0.0.1:7890配置好之后, 通过如下命令查看是否生效:
git config --global http.proxy
git config --global https.proxy 删除配置:
git config --global --unset http.proxy
git config --global --unset https.proxy参考 OpenSSL SSL_connect: Connection was reset in connection to github.com:443
iTerm2配置 Option+← Option+→ 按单词快速移动
路径: iTerm2->Preferences->Profiles->Keys->Key Mappings


iTerm2快速分屏
- ⌘ + Nfor a new window
- ⌘ + Tfor a new tab
- ⌘ + Dto split my pane vertically
- ⌘ + ⇧ + Dto split it horizontally
- 同时需要保持新拆分出的窗口目录与当前文件目录保持一致: iterm2-split-vertically-with-current-profile-with-same-working-directory
iTerm2分屏导航
- cmd-opt-arrow 进行分屏导航
- cmd-1/2/3 或者 cmd-arrow 进行Tab导航
git配置SSHKey访问
Maven设置阿里云镜像
Copy From 将maven源改为国内阿里云镜像
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                      http://maven.apache.org/xsd/settings-1.0.0.xsd">
  <localRepository/>
  <interactiveMode/>
  <usePluginRegistry/>
  <offline/>
  <pluginGroups/>
  <servers/>
  <mirrors>
    <mirror>
     <id>aliyunmaven</id>
     <mirrorOf>central</mirrorOf>
     <name>阿里云公共仓库</name>
     <url>https://maven.aliyun.com/repository/central</url>
    </mirror>
    <mirror>
      <id>repo1</id>
      <mirrorOf>central</mirrorOf>
      <name>central repo</name>
      <url>http://repo1.maven.org/maven2/</url>
    </mirror>
    <mirror>
     <id>aliyunmaven</id>
     <mirrorOf>apache snapshots</mirrorOf>
     <name>阿里云阿帕奇仓库</name>
     <url>https://maven.aliyun.com/repository/apache-snapshots</url>
    </mirror>
  </mirrors>
  <proxies/>
  <activeProfiles/>
  <profiles>
    <profile>  
        <repositories>
           <repository>
                <id>aliyunmaven</id>
                <name>aliyunmaven</name>
                <url>https://maven.aliyun.com/repository/public</url>
                <layout>default</layout>
                <releases>
                        <enabled>true</enabled>
                </releases>
                <snapshots>
                        <enabled>true</enabled>
                </snapshots>
            </repository>
            <repository>
                <id>MavenCentral</id>
                <url>http://repo1.maven.org/maven2/</url>
            </repository>
            <repository>
                <id>aliyunmavenApache</id>
                <url>https://maven.aliyun.com/repository/apache-snapshots</url>
            </repository>
        </repositories>             
     </profile>
  </profiles>
</settings>常用命令/操作
常用操作
- MAC怎么重置SMC/NVRAM/PRAM - Option+Command+P+R
- 开机选择启动磁盘 - 按住 option 键
- 重装系统 - 安装与你电脑兼容的 macOS 最新版本:Option-Command-R。
- 重新安装你电脑原始版本的 macOS(包括可用的更新):Option-Shift-Command-R。
- 重新安装当前版本的 macOS:Command-R。
 
硬件性能相关
- 查看CPU型号 - > sysctl machdep.cpu.brand_string machdep.cpu.brand_string: Intel(R) Core(TM) M-5Y71 CPU @ 1.20GHz
- 查看物理内存大小 - > sysctl -n hw.memsize 8589934592
- 加快TimeMachine备份的速度 - > sudo sysctl debug.lowpri_throttle_enabled=0
常用链接&工具
- 查询MacOS 支持的Mac型号: MacOS Compatibility Guide by Mac Model
- 查询Mac SN号码对应的硬件详细信息: Apple Serial Number Info
- 为老旧Mac安装新的 MacOS 系统: OpenCore Legacy Patcher
- MacOS各个版本官方下载地址: 如何下载和安装 macOS - 官方 Apple 支持 (中国)
- 如何创建MacOS磁盘镜像(方便随时重装系统): 创建可引导的 macOS 安装器 - 官方 Apple 支持 (中国)
新Mac初始化方式
新的Mac初始化, 按照上边这些步骤一个一个来, 确实需要花费不少时间.
尤其是自己喜欢折腾电脑, 这样导致的问题就更严重了.
因此调研了下初始化的方式: 
TimeMachine 方式
- 优点: 非常方便靠谱, 基本可以 1:1 无损地进行迁移
- 缺点: - 需要单独搞块硬盘用来作为TimeMachine的备份盘. 但现在硬盘价格也便宜, 因此问题倒也不大.
- 只支持低版本的TimeMachine迁移到同版本或者高版本的MacOS上.
 
这个问题就比较严重. 现在自己的TimeMachine是基于Monterey来构建, 但新淘来的15款MacBook12寸, 只能支持到BigSur的MacOS.
因此只能使用 OpenCore Legacy Patcher 来强制升级系统到Monterey; 但性能是否受影响就难说了.
Dotfile 方式
- 优点:- github 托管, 无需单独硬盘.
- 版本兼容性较好.
 
- 缺点:- 需要长期维护, 新增加啥配置或者软件, 都需要记得更新Dotfile.
- 不同Mac版本的兼容性也需要考虑.
 
自己暂时选用的是TimeMachine方式, 还算靠谱.
