macOS 常用配置命令和路径

配置命令

显示/隐藏 隐藏文件

  • 显示:defaults write com.apple.finder AppleShowAllFiles -bool true
  • 隐藏:defaults write com.apple.finder AppleShowAllFiles -bool false

这个没什么好说的= =

开启/关闭 HIDPI

  • 开启:sudo defaults write /Library/Preferences/com.Apple.windowserver DisplayResolutionEnabled -bool true
  • 关闭: sudo defaults delete /Library/Preferences/com.Apple.windowserver DisplayResolutionEnabled

此方法是开启原生的HIDPI,效果为当前分辨率/2

开启/关闭 校园网认证弹窗

  • 开启:sudo defaults write /Library/Preferences/SystemConfiguration/com.apple.captive.control Active -bool true
  • 关闭:sudo defaults write /Library/Preferences/SystemConfiguration/com.apple.captive.control Active -bool false

我猜没几个人愿意打开这个鬼东西的吧?

清除图标缓存

  • sudo rm -rf /Library/Caches/com.apple.iconservices.store

查看共享WIFI的所有连接客户端

  • arp -i en1 -a

开启隐藏Airport命令工具

  • sudo ln -s /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport /usr/sbin/airport

开启/关闭 MacBook充电提示音

  • 开启:sudo defaults write com.apple.PowerChime ChimeOnAllHardware -bool true; open /System/Library/CoreServices/PowerChime.app
  • 关闭:sudo defaults write com.apple.PowerChime ChimeOnAllHardware -bool false; killall PowerChime

添加与查看全局Git Ignore配置

  • 添加:git config --global core.excludesfile '~/.gitignore_global'
  • 查看:git config --get core.excludesfile

命令行调节系统音量

  • sudo osascript -e "set Volume 10"

Volume的范围为0-10

检查Xcode的完整性

  • spctl --assess --verbose /Applications/Xcode.app

注意一点:在对Xcode.app包中修改了任何文件都会检测为非官方版本

查看进程在搞什么飞机

  • sudo fs_usage -w -f filesys socketfilterfw

路径

  • iTunes的iDevices备份路径:~/Library/Application Support/MobileSync/Backup/
  • Xcode文档路径:~/Library/Developer/Shared/Documentation
  • Xcode插件路径:~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/
  • Xcode模板路径:/Applications/Xcode.app/Contents/Developer/Library/Xcode/Templates/Project Templates/
  • App crash report:~/Library/Developer/Xcode/Products/
  • 自动启动配置文件路径:/Library/LaunchDaemons/