Skip to main content

Setting Up a Mac From Zero

[TOC]

External Drive System

Tutorial video

Adjusting HiDPI

BetterDisplay software, available on GitHub.

Enable flexible scaling:

  1. Launch the app and open the app menu (find the BetterDisplay icon in the menu bar).

  2. Open Settings (gear icon at the bottom of the menu).

  3. Navigate to the Displays section and select the desired display.

  4. Enable Edit the default system configuration of this display model under the display you want to scale.

  5. Enable Enable flexible scaling in the option that appears below it.

  6. If you have done this for all relevant displays, click the Apply button in the red area that appears.

  7. Enter your administrator credentials and restart.

  8. After restarting, use the resolution slider in the app menu to scale the desktop.

    image-20240216231508460

Proxy Configuration

Edit ~/.zshrc in the terminal:

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

This adds command-line proxy settings.

Installing Homebrew

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

After installation, follow the prompts to add environment variables.

Install basic command-line tools:

brew install git
brew install vim
brew install wget
brew install curl

brew install btop
brew install tmux

Software

App Store

Xcode, WeChat, QQ, Baidu Netdisk, Feishu, Tencent Meeting, Sunflower, Evernote, NetEase Cloud Music, LogiOptions, NetEase Mail Master

Configuring the Terminal

Recommended: follow the documentation to install Oh My Zsh.

MuZhi's video (recommended) - installs directly into .zsh folder without Oh My Zsh

Reference video

YouTube video

Corresponding documentation

You can also add Google search as a fun extra.

image-20240216231646758

Configuring SSH and Keys

Setting Up the SSH Server:

  1. Enable SSH:

    • Open "System Preferences".
    • Click "Sharing".
    • Check "Remote Login" in the service list.
    • Choose which users can access: all users or specific users.
  2. Configure the firewall (if enabled):

    • Make sure the firewall allows inbound connections on the SSH port (default: 22).
  3. (Optional) Configure SSH options:

    • Open Terminal.
    • Edit the SSH config file, usually at /etc/ssh/sshd_config.
    • You can change settings like port number, login attempt limits, etc.
    • After modifying the config, restart the SSH service:
sudo launchctl stop com.openssh.sshd
sudo launchctl start com.openssh.sshd

Setting Up the SSH Client:

  1. Generate an SSH key (if you don't have one yet):

    • Open Terminal.
    • Run ssh-keygen and follow the prompts. This generates a public/private key pair.
    • The public key is saved at ~/.ssh/id_rsa.pub by default; the private key at ~/.ssh/id_rsa.
  2. Add the public key to a remote server:

    • Use ssh-copy-id to add your public key to the remote server's ~/.ssh/authorized_keys file, enabling passwordless login.
    • If the remote server doesn't have ssh-copy-id, manually copy the public key content into the remote server's authorized_keys file.
  3. Connect to the remote server:

    • Use ssh [username]@[remote_host] to connect, where [username] is your username on the remote server and [remote_host] is the IP address or hostname.

Setting Up C/C++ Environment

To set up a C/C++ development environment with OpenMP and MPI support on a fresh Mac:

  1. Install Xcode:

    • Xcode is Apple's official IDE, bundled with the Clang compiler and essential development tools. Download and install the latest version from the Mac App Store.
  2. Install Homebrew:

    • Homebrew is a convenient package manager for installing open-source software on Mac. Run this in Terminal:
      /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  3. Install GCC (for OpenMP support):

    • Mac ships with Clang, but Clang's OpenMP support is limited. Install GCC via Homebrew for better OpenMP support:
      brew install gcc
  4. Install MPI:

    • Choose an MPI implementation like Open MPI or MPICH, then install via Homebrew:
      brew install mpich
  5. Configure environment variables:

    • Add GCC to your PATH so you can use g++ directly for OpenMP code. Edit or create ~/.bash_profile and add:
      export PATH="/usr/local/opt/gcc/bin:$PATH"
      Then run source ~/.bash_profile to apply changes.
  6. Test the setup:

    • Write and compile a simple C++ program using OpenMP and MPI to verify everything works.
  7. CMake (optional but recommended):

    • CMake is a cross-platform build system that makes building projects easier across environments. Install via Homebrew:
      brew install cmake
  8. Development notes:

    • When compiling OpenMP code with GCC, add the -fopenmp flag.
    • When compiling MPI code, link the appropriate libraries, e.g. -lmpi and -lopen-rte for Open MPI.

Note: the above guidance is based on information up to 2021. Adjust as needed based on current Homebrew and package versions.

Python

To set up a Python development environment on a fresh Mac:

  1. Install Homebrew: Homebrew is a package manager for macOS. Open Terminal and run:

    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  2. Install Python: Install the latest stable Python 3 via Homebrew:

    brew install python
  3. Verify the installation: After installation, run python3 --version or python --version to check the installed version.

  4. Install pip: Python 3 usually comes with pip bundled. Check with:

    pip3 --version

    If it's missing or needs updating, install or upgrade via Homebrew:

    brew install pip

Installing Anaconda

Installing LaTeX

Installing Docker Desktop for Mac

Configuring VS Code

Yes, Visual Studio Code (VS Code) supports syncing your settings, extensions, and other personalizations via Settings Sync. To sync VS Code settings on a new Mac:

  1. Open VS Code.

  2. Use Cmd + Shift + P to open the Command Palette.

  3. Type Settings Sync: Turn On and select it to enable Settings Sync.

  4. You will be prompted to sign in with a Microsoft or GitHub account. Choose one and sign in. This is the account where your settings are stored and synced.

  5. After signing in, VS Code will ask what you want to sync. You can choose to sync extensions, settings, keyboard shortcuts, snippets, UI state, and more.

  6. Once you complete these steps on your new Mac, VS Code will begin syncing your previously saved settings.

Make sure Settings Sync is also enabled on your other devices and signed in with the same account, so your settings sync across devices. If you have workspace-specific settings, additional steps may be needed to ensure those sync as well.

Time Machine

Configure Time Machine.

Time Machine explanation