旧墨

MacOS常用操作汇总

2025/12/27
40
0

打开全部来源

sudo spctl --master-disable

Homebrew安装与卸载

/bin/zsh -c "$(curl -fsSL <https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh>)"
  • 替换为清华源

# 替换各个源
$ git -C "$(brew --repo)" remote set-url origin <https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git>
$ git -C "$(brew --repo homebrew/core)" remote set-url origin <https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git>
$ git -C "$(brew --repo homebrew/cask)" remote set-url origin <https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask.git>
 
# zsh 替换 brew bintray 镜像
$ echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles' >> ~/.zshrc
$ source ~/.zshrc
 
# bash 替换 brew bintray 镜像
$ echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles' >> ~/.bash_profile
$ source ~/.bash_profile
 
# 刷新源
$ brew update
  • 替换为中科大源

# 替换各个源
$ git -C "$(brew --repo)" remote set-url origin <https://mirrors.ustc.edu.cn/brew.git>
$ git -C "$(brew --repo homebrew/core)" remote set-url origin <https://mirrors.ustc.edu.cn/homebrew-core.git>
$ git -C "$(brew --repo homebrew/cask)" remote set-url origin <https://mirrors.ustc.edu.cn/homebrew-cask.git>
 
# zsh 替换 brew bintray 镜像
$ echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.zshrc
$ source ~/.zshrc
 
# bash 替换 brew bintray 镜像
$ echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile
$ source ~/.bash_profile
 
# 刷新源
$ brew update
  • Homebrew卸载

/bin/bash -c "$(curl -fsSL --insecure <https://gitee.com/ineo6/homebrew-install/raw/master/uninstall.sh>)"

Jdk多版本管理

https://www.jianshu.com/p/d628e8c6bf3d

侧边栏中文

https://www.jianshu.com/p/074dbf872146

Idea快捷键

https://zhuanlan.zhihu.com/p/78795243

腾讯文档恢复浅色

#!/bin/bash
# 🚀 Fix Tencent Docs (WeDoc) Always Light Mode on macOS
# 作者:MT 的 ChatGPT 脚本助手

echo "🔍 正在查找腾讯文档包名..."

# 查找腾讯文档相关的 Bundle ID
BUNDLE_ID=$(osascript -e 'id of application "腾讯文档"' 2>/dev/null || \\
             osascript -e 'id of application "WeDoc"' 2>/dev/null || \\
             osascript -e 'id of application "Wedoc"' 2>/dev/null || \\
             echo "")

# 如果找不到,用常见的几个候选名
if [[ -z "$BUNDLE_ID" ]]; then
  echo "⚠️ 未通过系统检测到包名,尝试常见候选..."
  for id in com.tencent.mac.tdappdesktop com.tencent.Wedoc com.tencent.wedoc.mac; do
    if [[ -f ~/Library/Preferences/$id.plist ]]; then
      BUNDLE_ID=$id
      break
    fi
  done
fi

if [[ -z "$BUNDLE_ID" ]]; then
  echo "❌ 未找到腾讯文档应用,请先安装或启动过一次后再运行此脚本。"
  exit 1
fi

echo "✅ 检测到腾讯文档包名:$BUNDLE_ID"
echo "⚙️  正在设置固定浅色模式..."

# 写入偏好项
defaults write "$BUNDLE_ID" NSRequiresAquaSystemAppearance -bool YES

# 清理缓存并关闭腾讯文档进程
killall cfprefsd 2>/dev/null
pkill -f tdappdesktop 2>/dev/null
pkill -f Wedoc 2>/dev/null

echo "✨ 设置完成!重新打开腾讯文档即可保持白色界面。"
echo "💡 若想恢复跟随系统,可运行:"
echo "    defaults delete $BUNDLE_ID NSRequiresAquaSystemAppearance"