My macOS Config

For my new M2 MacBook Air.

Terminal

Install ‘oh-my-zsh’ and plugins

  • 从App Store上下载Xcode(安装比较耗时,占用大约15GB), 或者,使用以下命令只安装 Xcode Commandline Tools (这个很快,占用仅300MB左右)

    1
    xcode-select --install
  • 安装oh-my-zsh (Official website: ohmyz.sh)

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

    Use Clash and the following shortcuts to proxy your terminal.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    # proxy, created on 2024.07.23
    enableproxy() {
    export https_proxy=http://127.0.0.1:7890;
    export http_proxy=http://127.0.0.1:7890;
    export all_proxy=socks5://127.0.0.1:7890;
    git config --global http.proxy http://127.0.0.1:7890;
    git config --global https.proxy https://127.0.0.1:7890;
    }
    disableproxy() {
    unset http_proxy;
    unset https_proxy;
    unset all_proxy;
    git config --global --unset http.proxy;
    git config --global --unset https.proxy;
    }

    Install plugins.

    zsh-syntax-highlighting

    1
    git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting

    Then, to enable these plugins, open ~/.zshrc and modify the line plugins=(git) to

    1
    plugins=(git zsh-syntax-highlighting)

    You may also enable some built-in useful plugins.

    1
    plugins=(git zsh-syntax-highlighting colored-man-pages extract sudo z)
1
zsh -c "$(curl -fsSL 'https://api.host.mintimate.cn/fileHost/public/download/1P0R')"

iTerm2

Download iTerm2: https://iterm2.com

My detailed theme config.

  • Install iTerm2 and set as default terminal. (Top-left corner, Iterm2, click “Make iTerm2 Default Term” in the dropdown menu)
  • Settings --> Appearance --> General —> Theme = Minimal.
  • Settings --> Profiles --> Colors --> Color Presets --> Solarized Dark High Contrast (Download from here and import it).
  • Settings --> Profiles --> Window --> Transparency = 13, Keep background colors opaque = true, Blur = 13, Columns = 115.
  • Install MesloLGS-NF Font (download from here) and use that font: Settings --> Profiles --> Text --> Set Font to MesloLGS-NF, size = 15.
  • Settings --> Profiles --> Terminal --> Turn on “Unlimited scrollback”.
  • Settings --> Advanced --> Search for “Scroll wheel sends arrow keys when in alternate screen mode” and turn it on.

Install HomeBrew

如果需要使用国内源,append the following to the end of ~/.zshrc

1
2
3
4
export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.ustc.edu.cn/brew.git"
export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.ustc.edu.cn/homebrew-core.git"
export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles"
export HOMEBREW_NO_AUTO_UPDATE=true

Command to install Homebrew.

1
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

国内镜像

1
2
/bin/bash -c "$(curl -fsSL https://cdn.jsdelivr.net/gh/Homebrew/install@HEAD/install.sh)"
brew update

Reference: Homebrew 源使用帮助 - USTC Mirror Help

In order to run third-party applications

  • Allow apps downloaded from ‘Anywhere’.

    1
    sudo spctl --master-disable

    Then in Settings --> Privacy & Security, you can see the option “Anywhere”.

  • sudo without password. Do with caution! Dangerous!

    1
    visudo

    Modify the line %admin ALL = (ALL) ALL to

    1
    %admin  ALL = (ALL) NOPASSWD:ALL

GUI

  • Modify launchpad icon layout (更新:macOS 26把启动台砍了,没用了)

    You can modify the row number and column number the launchpad displays.

    1
    2
    3
    defaults write com.apple.dock springboard-rows -int 5
    defaults write com.apple.dock springboard-columns -int 10
    killall Dock

    To restore default, use

    1
    2
    3
    defaults write com.apple.dock springboard-rows Default 
    defaults write com.apple.dock springboard-columns Default
    killall Dock
  • Finder settings

    Finder --> Settings --> Turn on “Show all filename extensions”

  • Safari

    Settings --> General --> Turn off “Open Safe files after downloading”.

    这样的话safari下载压缩包完成后就不会自动解压了

    Settings --> Advanced --> Turn on “Show features for web developers”. 启用safari的DevTools。

  • 如果使用非苹果键盘想互换command和option按键(windows和alt按键):

    Settings --> Keyboard --> Keyboard Shortcuts --> Modifier Keys

    非苹果键盘没有地球仪键,可能没法切换输入法,可在Input sources中把切换输入法快捷键设置成control+空格.

  • Hot corners 触发角

    Settings --> Desktop & Dock --> Hot corners (at the bottom)

  • Make jpg (instead of png) the default screenshot filetype. This can significantly reduce screenshot size.

    1
    defaults write com.apple.screencapture type jpg
  • Make ~/Library/ a visible folder.

    1
    chflags nohidden ~/Library
  • Modify Hostname

    Go to Settings, General, Sharing, scroll to the bottom.

  • Turn off ‘powernap’ and ‘tcpkeealive’. This disables wifi connection at system sleep to save battery power, but may result in features like ‘Find My Mac’ not to function properly. Do with caution! 没必要,别做了,这条命令对于M芯片的mac的耗电量影响微乎其微,但反而导致经常断网,没用。

    1
    2
    sudo pmset -a powernap 0
    sudo pmset -a tcpkeepalive 0
  • Fast Key Repeat Rate

    In Settings, Keyboard, set Key repeat rate to the highest.

  • Trackpad-related

    Settings --> Trackpad --> Point&Click --> Turn on “Tap to click”.

    Settings --> Trackpad --> More Gestures --> App Exposé, choose “Swipe Down with Three Features”

  • Vim

    Write to ~/.vimrc

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    set modelines=0    " CVE-2007-2438

    set nocompatible " Use Vim defaults instead of 100% vi compatibility
    set backspace=2 " more powerful backspacing

    " Don't write backup file if vim is being called by "crontab -e"
    au BufWrite /private/tmp/crontab.* set nowritebackup nobackup
    " Don't write backup file if vim is being called by "chpass"
    au BufWrite /private/etc/pw.* set nowritebackup nobackup

    let skip_defaults_vim=1

    syntax on

    set tabstop=4
    set softtabstop=4
    set shiftwidth=4
    set ruler
    set nu

Useful GUI Software

  • Parallels Desktop: 能运行Windows 11 ARM, Ubuntu ARM等虚拟机

    不免费,可能需要破解版: link

  • MOS: A lightweight tool used to let your mouse on macOS behave like Windows.

    开源软件,官网: mos.caldis.me

    Turn on “Launch on Login”.

    有些软件滑动起来会很怪(甚至完全没法用),如Adobe Acrobat、Blender等,可以添加exception, 对这些软件单独关闭 Smooth Scrolling.

  • Rectangle: Window manager.

    开源的窗口管理器

    https://github.com/rxhanson/Rectangle

  • Crossover: with the help of Apple Game Porting Toolkit (GPTK), it allows you to run Windows games on your mac. 能够转译运行Windows上的DirectX游戏。

    不免费,可能需要破解版。

Useful Command Line Software

  • Asitop: power measuring tool for Apple Silicon.

    Install with python and pip.

    1
    /usr/bin/python3 -m pip install asitop
  • Smartctl: a tool to view your hard disk usage.

    1
    brew install smartmontools

    Run with smartctl -a disk0.


My macOS Config
https://www.billhu.us/2024/32_macos/
Author
Bill Hu
Posted on
July 25, 2024
Licensed under