青蛙小白
目录
$ ls -latotal 8

macOS

homebrew

网络加速

直接使用代理,简单粗暴!

export all_proxy=socks5://127.0.0.1:1080

brew outdated

还可使用国内镜像源:

初始安装清华大学镜像源的hombebrew

安装Command Line Tools (CLT) for Xcode:

xcode-select --install
export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git"
export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git"
export HOMEBREW_INSTALL_FROM_API=1

export HOMEBREW_API_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles/api"
export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles"

git clone --depth=1 https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/install.git brew-install
/bin/bash brew-install/install.sh
rm -rf brew-install

安装成功后需将brew程序的相关路径加入到环境变量中。

vi ~/.zshrc

加入:

export HOMEBREW_API_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles/api"
export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles"
export PATH=$PATH:/opt/homebrew/bin

替换brew自己的源:

export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git"
brew tap --custom-remote --force-auto-update homebrew/command-not-found https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-command-not-found.git
brew update

另外homebrew中文网提供的安装脚本中内置了国内镜像源。

查看已安装软件包的依赖树

brew deps --tree --installed

列出顶级包

列出所有已安装但不是其他已安装包依赖项的包。

brew leaves

查看哪些包依赖这个包

brew uses --installed ca-certificates

看某包的构建/运行依赖树

brew deps --tree [email protected]

proxychains-ng

安装:

brew install proxychains-ng

配置:

sudo vi /opt/homebrew/etc/proxychains.conf
# 加入代理配置 ...

在不关闭SIP的情况下使用proxychains-ng

关于Mac上的系统完整性保护中有介绍,系统完整性保护(SIP)包含对以下系统部分的保护:

/System
/usr
/bin
/sbin
/var
Mac操作系统预装的App

brew安装的工具位于/opt/homebrew下,不受SIP的影响。

例如对于brew安装的wget:

brew install wget

which wget
/opt/homebrew/bin/wget

proxychains4 wget ifconfig.me

# 可以显示代理服务器的ip
cat index.html 

一般使用proxychains4和wget, rclone等工具进行命令行下的文件下载。

Xcode command line tools中带的git位于/usr/bin/git,受系统完整性保护,不能使用proxychains4。 但Git 2.0之后的版本支持socks5协议代理,可以通过在终端设置代理相关的环境变量。

export http_proxy='socks5://127.0.0.1:1080'
export https_proxy='socks5://127.0.0.1:1080'

git clone https://github.com/xxx/yyy

Docker + Colima

launchctl

launchctl是macOS系统上管理launchd守护进程的命令行工具,用于控制系统服务和后台任务。

查看所有非系统服务:

launchctl list | grep -v "com.apple"

删除服务:

launchctl remove xxx 
  • 用户服务通常位于~/Library/LaunchAgents
  • 第三方全局服务通常位于/Library/LaunchDaemons/Library/LaunchAgents

clash verge rev

开Tun模式安装的服务如何卸载:

sudo launchctl stop io.github.clash-verge-rev.clash-verge-rev.service
sudo launchctl unload /Library/LaunchDaemons/io.github.clash-verge-rev.clash-verge-rev.service.plist
sudo rm -rf /Library/PrivilegedHelperTools/io.github.clash-verge-rev.clash-verge-rev.service.bundle
mkdir -p ~/Backup
cp /Library/Preferences/SystemConfiguration/NetworkInterfaces.plist ~/Backup
sudo rm -f /Library/Preferences/SystemConfiguration/NetworkInterfaces.plist
评论