轻松设置新的Macbook
Easily setup new MacBooks

原始链接: https://catalins.tech/how-i-setup-new-macbooks/

配置新MacBook可以通过自动化安装和配置来简化。与其手动安装,不如使用Brewfile列出命令行工具、应用程序和字体,然后用`brew bundle`批量安装。macOS设置可以通过终端中的`defaults`实用程序进行配置,启用诸如轻触即点和隐藏.DS_Store文件等功能,无需在系统偏好设置中进行操作。终端效率可以通过Zsh插件来提升,包括Git快捷键、自动建议、语法高亮、别名提示以及增强的`cat`输出。Zsh别名进一步优化了命令执行。作者计划创建bash脚本来自动化此过程并添加更多命令。

这个Hacker News帖子讨论了配置新Macbook的方法。原文探讨了使用“defaults”变量和dotfiles进行配置。评论者建议使用Ansible playbook进行自动化设置,并附带示例配置链接。提到的替代方案包括使用迁移助理从旧Mac传输数据,使用Nix-Darwin管理配置,以及使用自定义shell脚本安装软件和应用设置。一些人告诫不要完全自动化安装,因为可能存在bug。讨论还涵盖了诸如brew bundle(用于创建Brewfiles)和macos-defaults.com(用于浏览macOS默认设置)之类的工具。几位评论者分享了自己的dotfiles仓库和设置脚本,供其他人使用和修改。
相关文章
  • (评论) 2025-04-24
  • 好的,我喜欢 WezTerm 2024-08-13
  • (评论) 2024-01-07
  • (评论) 2025-04-22
  • 我喜欢 Makefile 2024-09-23

  • 原文

    I recently got a new MacBook and procrastinated setting it up for a few days. Installing apps individually and configuring your machine manually feels like a huge chore.

    I also don't want to bring the trash from the previous machines with the Time Machine feature. I like to start fresh each time. If something is important enough, it'll find its way to the new machine.

    After posting the following on X and doing some research, I learned about the Brewfile and macOS defaults.

    Brewfile

    The Brewfile allows you to install command line utilities, applications, fonts and even Visual Studio Code (and forks/variants) extensions in bulk rather than installing them one by one.

    Here's my Brewfile:

    # command-line utilities
    
    brew "oven-sh/bun/bun"
    brew "git"
    brew "node"
    brew "ffmpeg"
    brew "cask"
    brew "postgresql@17"
    brew "zsh"
    brew "zsh-autosuggestions"
    brew "zsh-completions"
    brew "zsh-syntax-highlighting"
    brew "pnpm"
    brew "npm"
    brew "gh"
    
    # apps
    
    cask "cursor"
    cask "discord"
    cask "raycast"
    cask "whatsapp"
    cask "warp"
    cask "cleanshot"
    cask "google-chrome"
    cask "postman"
    cask "screen-studio"
    cask "imageoptim"
    cask "bitwarden"
    cask "docker"
    cask "obs"
    cask "elgato-stream-deck"
    cask "elgato-camera-hub"
    cask "zoom"
    cask "vlc"
    cask "pgadmin4"
    cask "nordvpn"
    cask "zed"
    cask "ngrok"
    
    # fonts
    
    cask "font-hack-nerd-font"
    cask "font-menlo-for-powerline"
    cask "font-jetbrains-mono"
    cask "font-jetbrains-mono-nerd-font"

    You can create the Brewfile in the root directory of your machine and run brew bundle once you're done with it.

    The bundle command installs all the things you specified in the file.

    Settings defaults

    macOS also provides the defaults utility to customize the settings of your MacBooks and certain applications.

    Instead of updating the settings through the UI, you can achieve the same things by using the defaults utility in the terminal.

    # Enable tap-to-click for the trackpad and show the correct state in System Preferences
    defaults write com.apple.AppleMultitouchTrackpad Clicking -bool true
    defaults -currentHost write -g com.apple.mouse.tapBehavior -int 1
    
    # Disable the .DS file creation
    defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true
    defaults write com.apple.desktopservices DSDontWriteUSBStores -bool true
    
    # Show the path bar in the Finder
    defaults write com.apple.finder "ShowPathbar" -bool "true" && killall Finder
    
    # Show hidden files in the Finder
    defaults write com.apple.finder "AppleShowAllFiles" -bool "false" && killall Finder
    
    # Keep folders on top in Finder
    defaults write com.apple.finder "_FXSortFoldersFirst" -bool "true" && killall Finder
    
    # Keep folders on top on Desktop
    defaults write com.apple.finder "_FXSortFoldersFirstOnDesktop" -bool "true" && killall Finder
    
    # Apply the settings
    /System/Library/PrivateFrameworks/SystemAdministration.framework/Resources/activateSettings -u

    This is very handy because you don't have to make all the changes manually.

    Zsh Plugins

    Lastly, I install my favorite 5 Zsh plugins:

    • Git - a plugin that provides useful Git shortcuts like gco instead of git checkout, for example.
    • Zsh-autosuggestions - autocomplete functionality based on your history of previous commands.
    • Zsh-syntax-highlighting - syntax highlighting for the commands you type in the terminal.
    • You-should-use - it reminds you of your aliases (shortcuts) when you use the full command. If you use git checkout instead of gco, it'll display the alias for the command, for example.
    • Zsh-bat - it improves the output of the cat command.

    Zsh Aliases for Terminal Productivity

    I use a handful of Zsh aliases (shortcuts) to save a few keystrokes and improve my terminal productivity.

    What's Next

    • Create bash scripts to easily run the installation and commands
    • Add more commands

    If you have any suggestions or feedback, please leave a comment.

    Pay what you like 🧡

    If you like this content and it helped you, please consider supporting this blog.

    联系我们 contact @ memedata.com