Skip to content

Mac使用记录

安装Xcode Command Line Tools

shell
xcode-select --install

安装完成后再次执行以上命令,出现以下文字说明安装成功

shell
xcode-select: error: command line tools are already installed, use "Software Update" to install updates

安装Brew

brew的安装要么使用梯子,要么使用国内源。为了以后省心建议直接选用国内源

shell
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
`source /Users/morax/.zprofile`

屏蔽系统更新

https://sysin.org/blog/disable-macos-update/

在hosts文件中添加网址屏蔽

shell
sudo vim /etc/hosts
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1             localhost


## Mac Software Update (sysin) sysin.org
127.0.0.1 swdist.apple.com
127.0.0.1 swscan.apple.com
127.0.0.1 swcdn.apple.com
127.0.0.1 gdmf.apple.com
127.0.0.1 mesu.apple.com
127.0.0.1 xp.apple.com

## App Store Update
127.0.0.1 gsp64-ssl.ls.apple.com

## Sublime Text
127.0.0.1 www.sublimetext.com
127.0.0.1 sublimetext.com
127.0.0.1 license.sublimehq.com

## Parallels
127.0.0.1 static.parallels.com
127.0.0.1 download.parallels.com.cdn.cloudflare.net
127.0.0.1 download.parallels.com
127.0.0.1 update.parallels.com.cdn.cloudflare.net
127.0.0.1 update.parallels.com
127.0.0.1 reportus.parallels.com.cdn.cloudflare.net
127.0.0.1 reportus.parallels.com
127.0.0.1 desktop.parallels.com.cdn.cloudflare.net
127.0.0.1 desktop.parallels.com
127.0.0.1 parallels.cn
127.0.0.1 parallels.com
127.0.0.1 parallels.de
127.0.0.1 parallels.es
127.0.0.1 parallels.fr
127.0.0.1 parallels.nl
127.0.0.1 parallels.pt
127.0.0.1 parallels.ru
127.0.0.1 parallelskorea.com
127.0.0.1 parallels.cn
127.0.0.1 parallels.com
127.0.0.1 parallels.de
127.0.0.1 parallels.es
127.0.0.1 parallels.fr
127.0.0.1 parallels.nl
127.0.0.1 parallels.pt
127.0.0.1 parallels.ru
127.0.0.1 parallelskorea.com
127.0.0.1 pax-manager.myparallels.com
127.0.0.1 myparallels.com
127.0.0.1 my.parallels.com

清除dock栏更新角标

打开 “终端”,执行如下命令(可能需要重启才能生效):

text
defaults write com.apple.systempreferences AttentionPrefBundleIDs 0
Killall Dock

如果无法去除,再执行如下命令即可(可能需要重启才能生效):

text
defaults delete com.apple.systempreferences AttentionPrefBundleIDs
defaults delete com.apple.systempreferences DidShowPrefBundleIDs
killall Dock

经过测试在 Monterey 中进行 hosts 屏蔽后再次检查软件更新,会自动清除更新标记。

Curl设置代理

shell
# 设置 http proxy
export http_proxy="http://127.0.0.1:7890"

# 设置 https proxy
export https_proxy="http://127.0.0.1:7890"

# 取消 http,https 代理
unset http_proxy
unset https_proxy

# 测试代理是否设置成功
curl https://www.google.com

安装Qt

2025-05-14日更新

现在建议使用官方在线安装器进行安装,但是使用 Qt Creator 16.0.1 在 Mac OS 12.5 中有问题,无法正常打开使用,建议下载其他版本。可以使用官方仓库下载,也可以使用镜像仓库进行下载,在 Qt Creator 仓库中的相对路径为 /official_releases/qtcreator/

Qt的安装依赖于Xcode Command Line Tools,先安装Xcode Command Line Tools后在安装qt

首先在qt官网下载安装程序:https://www.qt.io/download-qt-installer-oss?hsCtaTracking=99d9dd4f-5681-48d2-b096-470725510d34|074ddad0-fdef-4e53-8aa8-5e8a876d6ab4

M1版本的Mac电脑安装qt6.3以上的版本可以直接获得qt对arm架构的支持,如果想要安装qt5.x版本需要使用源码编译安装或者使用brew安装。鉴于源码编译安装的复杂性建议使用brew安装,可以在终端直接使用brew search qt查找qt5的版本,我选择qt@5则使用命令brew install qt@5进行安装,安装成功后终端会有以下输出

shell
We agreed to the Qt open source license for you.
If this is unacceptable you should uninstall.

You can add Homebrew's Qt to QtCreator's "Qt Versions" in:
  Preferences > Qt Versions > Link with Qt...
pressing "Choose..." and selecting as the Qt installation path:
  /opt/homebrew/opt/qt@5

qt@5 is keg-only, which means it was not symlinked into /opt/homebrew,
because this is an alternate version of another formula.

If you need to have qt@5 first in your PATH, run:
  echo 'export PATH="/opt/homebrew/opt/qt@5/bin:$PATH"' >> ~/.zshrc

For compilers to find qt@5 you may need to set:
  export LDFLAGS="-L/opt/homebrew/opt/qt@5/lib"
  export CPPFLAGS="-I/opt/homebrew/opt/qt@5/include"
==> Summary
🍺  /opt/homebrew/Cellar/qt@5/5.15.10_1: 10,845 files, 344.8MB
==> Running `brew cleanup qt@5`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).

因为mac无法直接访问/opt文件夹,所以需要先对安装的目录进行软连接的创建

shell
cd
cd Downloads
ln -s  /opt/homebrew/Cellar/qt@5/5.15.10_1 ./qt

创建软连接之后打开qt的配置页面添加qt版本

image-20231011231535912

添加qt版本之后添加构建套件,qt版本选择刚才添加的即可。

解决OBS不能录制系统音频

方法来自知乎:心上

shell
brew install background-music

效果如下:

它可以针对每个软件进行声音的控制,而且Touch Bar仍然可以控制声音大小

然后再去OBS里添加音频采集,就可以采集系统声音里,还不影响其他设置(麦克风)。