Mac Notes

笔记介绍

这是一份 mac 折腾配置以及各种改造的精华笔记, 可以帮你从头到尾打造一个极为顺手的 mac.

在Windows端配合sux 可以统一 win & mac 的使用体验.

. . .

改键Karabiner(已经用hammerspoon完全替代)

改键软件 Karabiner-Elements 的配置得直接覆盖他的配置文件 karabiner.json (它的配置文件路径在 app 里的 misc 里有),
弄完之后记得去mac的设置-Keyboard-Keyboard Shortcuts-Input Sources-Select next source in Input menu里更改快捷键为ctrl+option+space

参考:

Mac读写NTFS格式移动硬盘(使用NTFS Disk by Omi也可以, 但是buhoNTFS更好因为免费)

打开mac自带的Disk Utility这个软件 , 右键选中你的 USB 磁盘,记住这个页面的表格中的右下角的Device是啥(这个就是你的 NTFS 磁盘标识符, 一般叫做类似于disk2s1的名字), 然后点击 “Unmount”, 打开 terminal , 然后在里面输入下面的命令 (记住要把里面的”disk2s1” 换成你的NTFS磁盘的标识符, ):

  1. Diskutil list
  2. Sudo mkdir /Volumes/disk2s1
  3. Sudo mount -t ntfs -o rw,auto,nobrowse /dev/disk2s1 /Volumes/disk2s1
  4. sudo ln -s /Volumes/disk2s1 ~/Desktop/disk2s1

这是在桌面创建了一个软链接即快捷方式。但是这个软链接不管是否硬盘都会一直留在桌面,不介意的可以到此结束了。那么如何将这个桌面上的磁盘隐藏掉了呢?其实也不是隐藏,只是换了个存在的地方 —— 将快捷方式拖入 Finder 的侧边栏即可。

科学上网

科学上网软件: ClashX
下载地址: https://itlanyan.com/trojan-clients-download/

步骤:

  1. 去 just my socks 拷贝那些服务节点的配置然后去google搜“ss配置转clash配置”的网站(但是似乎很有可能会泄露相关 ss 密码之类的),比如 https://subconverter.speedupvpn.com , 然后在线转换为clash的配置然后点击 ClashX 的菜单栏的图标, 然后 Config-Remote Config-Manage-Add
  2. 如果发现上不了网的话, 点击 ClashX 的图标, 然后 Config-Open Config Folder 查看生成的 config 文件是否和 本 github 项目的 clashx里的类似
  3. 请不要打开 clashx 的”设置为系统代理”, 否则剪映等一些软件无法联网,
    1. 但此时 safari 也会翻不了墙 (以下教程参考 https://www.youtube.com/watch?v=pAY8pNou9Gk)
      1. 此时需要先把 safari_proxy 文件夹中的 proxy.pac(这个是由 edge 的 SwitchyOmega插件里的配置生成的) 放到 /Library/WebServer/Documents 里
      2. 然后在设置-网络-高级-代理的Automatic proxy configuration 里输入 http://127.0.0.1/proxy.pac, 然后点击 右下角的 ok, 点击完ok之后会退回上一层菜单, 然后再点击 Apply
      3. 然后在 terminal 里输入命令 sudo apachectl start
      4. 去 safari 的地址栏输入http://127.0.0.1/proxy.pac 测试一下是否能访问这个, 有内容说明成功了, 此时再看看是否能谷歌/油管
    2. 此时还有个问题就是:可能会因为其它软件给关掉,如 ClashX 设置为系统代理的时候会把这个 pac 给清除掉, 所以我们需要检查一下 hammerspoon 里的 init.lua是否有 networksetup -setautoproxyurl 相关的代码, 有的话就会自动在激活 safari 的时候自动设置一下 pac 设置(相关代码其实是参考了 https://nowtime.cc/macos/1753.html , networksetup -setautoproxyurl "Wi-Fi" "http://127.0.0.1/proxy.pac" , 这个 “Wi-Fi” 是通过命令 networksetup -listallnetworkservices 拿到的)

触摸板增强

软件: betterTouchTool
破解版的得把下面这几句加到clashx当前所用的config文件的rules里来屏蔽下面这些地址

- DOMAIN-KEYWORD,folivora.ai,REJECT
- DOMAIN-KEYWORD,www.folivora.ai,REJECT
- DOMAIN-KEYWORD,updates.boastr.net,REJECT
- DOMAIN-KEYWORD,updates.folivora.ai,REJECT

加完之后去浏览器测试一下是否能打开这几个网址, 打不开则为屏蔽成功,
然后再打开betterTouchTool。

jetbrain-crack

用jetbrain_crack 文件夹里 的 ja-netfilter, 然后参考下方链接来破解即可, 适用于 jb2022.1 的全家桶

clion使用的时候切记: 要把项目目录以及各种觉得要mark的目录右键Mark directory as一下, 然后再项目根目录Reload Cmake Project

搜狗输入法皮肤

自己做了仨, 黑白灰

另外的好东西高仿 mac风格: Rime 鼠须管输入法皮肤效果 https://ssnhd.com/2022/01/11/rime-skin/

Alfred

hammerspoon

装好 hammerspoon 之后, 把~下的.hammerspoon文件夹里的删除, 然后将本项目中的 hammerspoon 文件夹的内容放到 ~下的.hammerspoon文件夹里

禁止cleanmymacx即使退出它的HealthMonitor还一直后台运行(App Cleaner & Uninstaller更好用)

问题:虽然CleanMyMacX软件被吹嘘的很厉害,在用起来感觉也可以帮助更好的清理电脑,但是它一直后台运行,还终止不了,一直监控Mac的信息情况,个人觉得很是鸡肋,在使用的时候打开用就行了,平常没必要一直常驻,对于内存紧张的朋友来说太吃内存了。

经过试验,可以修改权限解决,不需要删除文件,也不会出现system.log中的异常日志。

解决办法:

  1. 打开终端输入以下
    • chmod 400 "/Applications/CleanMyMac X.app/Contents/Library/LoginItems/CleanMyMac X Menu.app/Contents/Library/LoginItems/CleanMyMac X HealthMonitor.app/Contents/MacOS/CleanMyMac X HealthMonitor"
    • chmod 400 "/Applications/CleanMyMac X.app/Contents/Library/LoginItems/CleanMyMac X Menu.app/Contents/Library/LaunchServices/com.macpaw.CleanMyMac4.Agent"
    • chmod 400 "/Applications/CleanMyMac X.app/Contents/Library/LaunchServices/com.macpaw.CleanMyMac4.Agent"
  2. 然后去活动监视器终止CleanMyMacX所有进程即可。

启动台行列

【终端】输入或粘贴以下命令,修改后面的数字更改行列数。

  • 行数 defaults write com.apple.dock springboard-rows -int 9
  • 列数 defaults write com.apple.dock springboard-columns -int 10

最后输入以下命令 killall Dock

程序坞降低显示延迟

如果你习惯隐藏程序坞,鼠标放在屏幕底部,默认显示程序坞非常慢,你可以在【终端】输入或粘贴下面命令,将数值改为 0,这样,显示程序坞会变的很快。

defaults write com.apple.dock autohide-delay -int 0

最后输入以下命令 killall Dock

允许任何来源

安装非 App Store 里应用,可能会出现无法安装的情况,需要打开任何来源。【终端】输入或粘贴以下命令,按回车键。

sudo spctl --master-disable

密码位数

管理员默认密码至少为 4 位,【终端】输入或粘贴以下命令支持将密码改为 1 位。

pwpolicy -clearaccountpolicies

深色主题显示浅色窗口

程序坞和菜单栏深色,窗口是浅色。

【终端】输入或粘贴以下命令,按回车键, 注销并重新登录 Mac, 系统偏好设置 - 通用 - 深色。defaults write -g NSRequiresAquaSystemAppearance -bool Yes

恢复原样: defaults delete -g NSRequiresAquaSystemAppearance

Mac 删除原生 ABC 英文输入法(macos14.0实测已经失效)

删除系统英文 ABC,只保留一个输入法,这样搜狗输入法只需按 Shift 即可切换中英文。

  1. (这一步可以不做, 因为 sip 关闭之后 iOS 程序在 mac 就不能运行了, 所以先不做等发现删不掉 abc再来做吧, 关闭 sip 之后删除 abc 输入法再打开sip也可以 )先关闭 系统完整性保护SIP, 参考 系统完整性保护SIP
  2. 前往自己home 目录下的 ~/Library/Preferences/ 文件夹,找到 com.apple.HIToolbox.plist 文件, 先备份 cp com.apple.HIToolbox.plist com.apple.HIToolbox.plist.bak
  3. 删除 AppleEnabledInputSources 下的

    <dict>
    <key>InputSourceKind</key>
    <string>Keyboard Layout</string>
    <key>KeyboardLayout ID</key>
    <integer>252</integer>
    <key>KeyboardLayout Name</key>
    <string>ABC</string>
    </dict>
  4. 然后保存

  5. 重启 Mac。

恢复原样: 不必担心此操作给电脑带来异常,一切正常。还原打开系统偏好设置 → 键盘 → 输入法 → 添加 ABC 即可。

🐛 Fix: CursorUIViewService Memory Leak on macOS

⚠️ The Problem

If you are experiencing severe typing lag, system stuttering, or heavy battery drain on macOS Sonoma (14) or macOS Sequoia (15), you might be a victim of the CursorUIViewService memory leak.

When checking Activity Monitor, you will likely see:

  • CursorUIViewService (or cursoruiviewservice) marked as “Not Responding”.
  • The process consuming massive amounts of RAM (often between 10GB and 30GB+).
  • Extreme CPU usage or an “idle exit: dirty” state.

What is CursorUIViewService?

Introduced in macOS Sonoma, this background process renders the redesigned text cursor. Specifically, it is responsible for displaying the floating blue Caps Lock indicator and the input language popup that appears dynamically next to your typing caret.

Why does it leak memory?

Due to a bug in Apple’s UIKit rendering implementation on macOS, the service fails to destroy the UI windows it creates. Every time you switch inputs, toggle Caps Lock, or wake your Mac from sleep, it spawns tiny, invisible off-screen windows. Over a few days of uptime, it can accumulate thousands of these “ghost windows”, maxing out your unified memory and deadlocking the window server.

Accelerants: This leak happens much faster if you use third-party keyboard, clipboard, or macro apps that constantly query input sources (e.g., Keyboard Maestro, Input Source Pro, Logi Options+).


🛠️ Solutions

Since Apple has not officially patched this bug as of macOS Sequoia, the best and most reliable fix is to disable the redesigned cursor entirely. This will turn off the floating Caps Lock/Language indicators, but it will completely stop the memory leak and return your typing experience to normal.

  1. Open the Terminal app (Cmd + Space > type “Terminal”).
  2. Copy and paste the following commands to create the necessary directory (if it doesn’t exist) and apply the system feature flag override:
sudo mkdir -p /Library/Preferences/FeatureFlags/Domain
sudo defaults write /Library/Preferences/FeatureFlags/Domain/UIKit.plist redesigned_text_cursor -dict-add Enabled -bool NO
  1. Press Enter and type your Mac’s administrator password when prompted (your password won’t show on screen while typing, which is normal).
  2. Restart your Mac for the changes to take effect.

Note: After restarting, your text cursor will revert to the classic macOS style. The floating blue Caps Lock indicator will no longer appear, and the memory leak will be gone.

Method 2: The Temporary Fix (Clear RAM immediately)

If you are in the middle of working and cannot restart your computer right now, you can force-kill the process to instantly reclaim your RAM.

  1. Open Activity Monitor.
  2. Search for cursoruiviewservice in the top right corner.
  3. Select the process (it will likely be highlighted in red).
  4. Click the X button at the top of the window and select Force Quit.

Note: The system will automatically restart the process a few seconds later. This will fix the lag temporarily, but the memory leak will slowly build up again until you apply Method 1 or restart your Mac.


🔄 How to Revert the Changes

If a future macOS update officially patches this bug and you want the floating cursor indicators back, you can easily re-enable the feature:

  1. Open Terminal.
  2. Run the following command:
sudo defaults write /Library/Preferences/FeatureFlags/Domain/UIKit.plist redesigned_text_cursor -dict-add Enabled -bool YES
  1. Restart your Mac.

📌 References & Community Discussions

terminal相关

install oh-my-zsh

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

install powerlevel10k主题 & 路径颜色改色改成紫色

install p10k: git clone --depth=1 https://github.com/romkatv/powerlevel10k.git "${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k"

Open ~/.zshrc, find the line that sets ZSH_THEME, and change its value to "powerlevel10k/powerlevel10k"

(optional)不改色的话, 默认是蓝色太亮看不清又伤眼

  1. vim ~/.p10k.zsh
  2. 找到 POWERLEVEL9K_DIR_BACKGROUND 然后改成 typeset -g POWERLEVEL9K_DIR_BACKGROUND=128
  3. 保存
  4. source ~/.p10k.zsh

fzf-安装与配置

  1. 安装 fd (fd 使用 brew install fd命令来安装)
  2. 用 brew 安装: brew install fzf
  3. put the fzf-conf-code below to ~/.zshrc,
  4. 然后 vim ~/.zshrc, 找到七八十行左右 plugins=(git)的位置 比如原来是 plugins=(git) 则改为 plugins=(git tab-to-find), source ~/.zshrc 或者重启 zsh
  5. then you can use
    1. option+f to search current directory command history;
    2. option+r to search global command history;
fzf-conf-code
# ==========================================
# fzf history configuration
# ==========================================

# Keep global history search available through fzf's built-in widget.
# Option+R: global command history
bindkey '^[r' fzf-history-widget

# Option+F: commands previously run from the current working directory.
# Commands are recorded in separate files, one per exact directory path.
_FZF_DIR_HISTORY="$HOME/.zsh_directory_history"
mkdir -p "$_FZF_DIR_HISTORY"

_fzf_record_dir_history() {
# preexec receives the command line about to be executed as $1.
# Store each command as one history entry. Multiline commands are not
# reliably represented by this simple line-oriented log.
local dir_hash
dir_hash=$(printf '%s' "$PWD" | shasum | cut -c1-16) || return
print -r -- "$1" >> "$_FZF_DIR_HISTORY/$dir_hash"
}

# Avoid registering the same hook more than once if ~/.zshrc is sourced again.
autoload -Uz add-zsh-hook
add-zsh-hook -d preexec _fzf_record_dir_history 2>/dev/null
add-zsh-hook preexec _fzf_record_dir_history

fzf-history-current-directory() {
local dir_hash history_file selected
dir_hash=$(printf '%s' "$PWD" | shasum | cut -c1-16) || return
history_file="$_FZF_DIR_HISTORY/$dir_hash"

if [[ ! -s "$history_file" ]]; then
zle -M "No command history recorded for this directory yet"
return
fi

selected=$(fzf --no-sort --tac --query="$LBUFFER" < "$history_file")

if [[ -n "$selected" ]]; then
LBUFFER="$selected"
RBUFFER=""
fi
zle redisplay
}

zle -N fzf-history-current-directory
bindkey '^[e' fzf-history-current-directory