Skip to content

Latest commit

 

History

History
135 lines (108 loc) · 7.8 KB

macos.md

File metadata and controls

135 lines (108 loc) · 7.8 KB
  • [[BSD]], [[Linux]]
  • [[Objective-C]], [[swift]]

Learn

Common Usage

  • System infomation
    • brew install neofetch
  • CPU infomation
    • sysctl -a | sort | grep cpu
    • sysctl -n hw.ncpu
    • sysctl -n hw.physicalcpu
  • 清屏 Terminal clear (实际上仅是滚动光标至顶部)
  • 彻底清屏 Termimal cmd + k
  • 选中多个文件 command+option+i 查看总大小
  • 查看 Bundle ID:
    • osascript -e 'id of app "SomeApp"'
    • mdls -name kMDItemCFBundleIdentifier -r AbsolutePathOfSomeApp.app
  • 查看当前监听的端口列表: netstat -AaLlnW

Softwares

  • Homebrew: 🍺 The missing package manager for macOS (or Linux)
  • Homebrew Cask: 🍻 A CLI workflow for the administration of macOS applications distributed as binaries

Command-line

Menu-bar

Finder

  • Quick Look plugins List of useful Quick Look plugins for developers
    • install all brew install qlcolorcode qlstephen qlmarkdown quicklook-json qlimagesize suspicious-package apparency quicklookase qlvideo
    • install more brew install provisionql quicklookapk quicklook-pat webpquicklook syntax-highlight
  • Go2Shell opens a terminal window to the current directory in Finder. brew cask install go2shell
  • OpenInTerminal Finder Toolbar app for macOS to open the current directory in Terminal, iTerm, Hyper or Alacritty.

Applications

Xcode

  • Xcode 缓存及垃圾文件清理
    • 删除旧设备支持 ~/Library/Developer/Xcode/iOS DeviceSupport
    • 删除旧模拟支持 ~/Library/Application Support/iPhone Simulator
    • 项目索引及日志 ~/Library/Developer/Xcode/DerivedData

Projects

Tools

  • mackup Keep your application settings in sync (OS X/Linux)
  • How to set a file or folder to be ignored
    • If you’re running macOS 12.3 or earlier:
      • Ignore it xattr -w com.dropbox.ignored 1 '/Users/yourname/Dropbox (Personal)/YourFileName.pdf'
      • Don't ignore xattr -d com.dropbox.ignored '/Users/yourname/Dropbox (Personal)/YourFileName.pdf'
    • If you’re running macOS 12.5 or later and have the updated version of Dropbox for macOS on File Provider:
      • Switch it xattr -d 'com.apple.fileprovider.ignore#P' '/Users/yourname/Library/CloudStorage/Dropbox-Personal/YourFileName.pdf'

FAQs

  • How to identify the terminal from a script?
    • $TERM_PROGRAM, iTerm sets it to iTerm.app, and Terminal.app to Apple_Terminal.
  • Mac的最大连接数限制和端口的相关参数的设置
  • 让终端走代理的几种方法
  • 网络编程 macOS 总是弹出防火墙链接确认
  • macOS 删除 chrome 地址栏联想内容
    • 按向下箭头键以突出显示相应内容,然后按 Shift + fn + Delete 键
  • Mac关闭顽固的开机启动程序
    • 使用登录项添加自启动项 设置 -> 用户与群组 -> 登录项
    • 使用 Homebrew brew services [run/start/stop/restart/../list/help]
    • 使用 launchctl 工具
      • 所在目录:
        ~/Library/LaunchAgents        # 特定用户登录后以当前用户启动,第三方程序一般都放这里
        /Library/LaunchAgents         # 任一用户登录后以当前用户启动,管理员使用
        /Library/LaunchDaemons        # 系统装载时以root用户启动,管理员使用
        /System/Library/LaunchAgents  # 系统组件,任一用户登录后以当前用户启动
        /System/Library/LaunchDaemons # 系统组件,系统装载时以root用户启动
      • launchctl list 查看当前所有自启动项
      • launchctl load XXX 添加自启动项
      • launchctl unload XXX 删除自启动项
      • for example
        # 以下重启后无效
        launchctl stop /Library/LaunchAgents/com.epson.esua.launcher.plist
        launchctl stop /Library/LaunchAgents/com.epson.eventmanager.agent.plist
        launchctl stop /Library/LaunchAgents/com.epson.scannermonitor.plist
        launchctl unload /Library/LaunchAgents/com.epson.esua.launcher.plist
        launchctl unload /Library/LaunchAgents/com.epson.eventmanager.agent.plist
        launchctl unload /Library/LaunchAgents/com.epson.scannermonitor.plist
      • 修改 plist 文件,将 KeepAlive 和 RunAtLoad 等改为 false
  • xargs 之类的 shell 命令,参数格式与 Linux 有些不一样,如何与 Linux 统一起来?
    • 需要 GNU 系列工具 brew install coreutils gnu-sed
    • 把 PATH 路径放到前面,确保使用的都是 brew 安装的 GNU 命令
  • 重置 launchpad:defaults write com.apple.dock ResetLaunchPad -bool true; killall Dock
  • 弹框无法关闭 Command + Option + Shift + Ecs
  • MacBook Pro充不进电?
  • macOS App debug

Resources

  • awesome-mac Now we have become very big, Different from the original idea. Collect premium software in various categories. https://git.io/macx
  • awesome-macOS A curated list of awesome applications, softwares, tools and shiny things for macOS.

applications