Setting up the 2021 macbook pro M1 development environment

This is the record of the process of changing to the M1 chip.

OS configuration

Change the screenshot storage location

1
2
mkdir ~/screenshot
defaults write com.apple.screencapture location ~/screenshot

Modify screenshot filename prefix

Default will be this 截圖 2022-04-29 上午11.58.03.png

1
defaults write com.apple.screencapture name "screenshot"

modified to become screenshot 2022-04-29 下午4.19.43.png

Change a screenshot to JPG

The default is to save png, the following command is changed to jpg.

1
defaults write com.apple.screencapture type jpg

You can also change to pdf tiff gif.

ssh key setup

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
% ssh-keygen -t ed25519 -C "samzhu'mac" -P ""
Generating public/private ed25519 key pair.
Enter file in which to save the key (/Users/samzhu/.ssh/id_ed25519):
Created directory '/Users/samzhu/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /Users/samzhu/.ssh/id_ed25519
Your public key has been saved in /Users/samzhu/.ssh/id_ed25519.pub
The key fingerprint is:
SHA256:ZG/BLmGG0QbjTIPhZ3MPxKhVgnzchM92bRvLTdR2HWw github_spike19820318
The key's randomart image is:
+--[ED25519 256]--+
| ..=BX+ .oo|
| .++*B=. .E=|
| .+B+O o. ....|
| .o B+*..+ . |
| .S.=o * |
| o + . |
| |
| |
| |
+----[SHA256]-----+

% cat ~/.ssh/id_ed25519.pub

copy id_ed25519.pub to github.

The old way.

1
ssh-keygen -t rsa -b 2048 -C "samzhu'mac" -P ""

if Host key verification failed.

1
ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts

Git config

1
2
3
4
5
git config --global user.name samzhu
git config --global user.email spikexxxx@gmail.com

git config user.name "samzhu"
git config user.email "spikexxxx@gmail.com"

Application software

Rosetta 2

Rosetta 2 enables a Mac with Apple silicon to use apps built for a Mac with an Intel processor.
Installing Rosetta

VSCode(Apple Silicon)

https://code.visualstudio.com/download

Extension

Docker(Apple Silicon) & docker-compose

https://www.docker.com/get-started/

jdownloader(Apple Silicon)

https://jdownloader.org/download/index

DBeaver(Apple Silicon)

https://dbeaver.io/

KKBox (Intel)

https://www.kkbox.com/tw/tc/

Stoplight Studio (Intel)

https://stoplight.io/studio

Development tools

SDKMAN

https://sdkman.io/install

1
2
curl -s "https://get.sdkman.io" | bash
source "$HOME/.sdkman/bin/sdkman-init.sh"

Java (use SDKMAN)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
% sdk list java
================================================================================
Available Java Versions for macOS ARM 64bit
================================================================================
Vendor | Use | Version | Dist | Status | Identifier
--------------------------------------------------------------------------------
Corretto | | 18 | amzn | | 18-amzn
| | 18.0.1 | amzn | | 18.0.1-amzn
| | 17.0.3.6.1 | amzn | | 17.0.3.6.1-amzn
| | 17.0.2.8.1 | amzn | | 17.0.2.8.1-amzn
Java.net | | 19.ea.18 | open | | 19.ea.18-open
| | 19.ea.5.lm | open | | 19.ea.5.lm-open
| | 18 | open | | 18-open
| | 18.0.1 | open | | 18.0.1-open
| | 17.0.2 | open | | 17.0.2-open
Liberica | | 18.fx | librca | | 18.fx-librca
| | 18 | librca | | 18-librca
| | 17.0.2.fx | librca | | 17.0.2.fx-librca
| | 17.0.2 | librca | | 17.0.2-librca
| | 11.0.14 | librca | | 11.0.14-librca

install

1
2
sdk install java 17.0.2-librca
sdk default java 17.0.2-librca

test

1
2
3
4
% java --version
openjdk 17.0.2 2022-01-18 LTS
OpenJDK Runtime Environment (build 17.0.2+9-LTS)
OpenJDK 64-Bit Server VM (build 17.0.2+9-LTS, mixed mode, sharing)

Homebrew

https://brew.sh/

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

==> Checking for `sudo` access (which may request your password)...
Password:
==> This script will install:
/opt/homebrew/bin/brew
/opt/homebrew/share/doc/homebrew
/opt/homebrew/share/man/man1/brew.1
/opt/homebrew/share/zsh/site-functions/_brew
/opt/homebrew/etc/bash_completion.d/brew
/opt/homebrew
==> The following new directories will be created:
/opt/homebrew/bin
/opt/homebrew/etc
...
Downloading Command Line Tools for Xcode
==> Homebrew is run entirely by unpaid volunteers. Please consider donating:
https://github.com/Homebrew/brew#donations

==> Next steps:
- Run these two commands in your terminal to add Homebrew to your PATH:
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/samzhu/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"
- Run brew help to get started
- Further documentation:
https://docs.brew.sh

test

1
2
3
brew --version
Homebrew 3.4.7
Homebrew/homebrew-core (git revision af15a30b144; last commit 2022-04-21)

upgrade

1
brew update --force --quiet

Terraform (use Homebrew)

https://www.terraform.io/downloads

1
2
brew tap hashicorp/tap
brew install hashicorp/tap/terraform

NVM (use Homebrew) & NodeJS

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
% brew install nvm
Please note that upstream has asked us to make explicit managing
nvm via Homebrew is unsupported by them and you should check any
problems against the standard nvm install method prior to reporting.

You should create NVM's working directory if it doesn't exist:

mkdir ~/.nvm

Add the following to ~/.zshrc or your desired shell
configuration file:

export NVM_DIR="$HOME/.nvm"
[ -s "/opt/homebrew/opt/nvm/nvm.sh" ] && \. "/opt/homebrew/opt/nvm/nvm.sh" # This loads nvm
[ -s "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm" ] && \. "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm" # This loads nvm bash_completion

You can set $NVM_DIR to any location, but leaving it unchanged from
/opt/homebrew/opt/nvm will destroy any nvm-installed Node installations
upon upgrade/reinstall.

Type `nvm help` for further information.
==> Summary
🍺 /opt/homebrew/Cellar/nvm/0.39.1_1: 9 files, 184.1KB
==> Running `brew cleanup nvm`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).

List all installable versions

1
nvm ls-remote

Install the specified version

1
nvm install v16.15.0

Uninstall

1
nvm uninstall v15.12.0

Select the version to use

1
nvm use v15.12.0

Show the version currently in use

1
nvm current

Set default node version

1
nvm alias default <version>

Using nvm in a project, create a .nvmrc file with the content:

1
v15.12.0

In the terminal we can use which node to see where our node is installed

gcloud CLI

https://cloud.google.com/sdk/docs/install#mac

1
2
3
4
curl https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-cli-382.0.0-darwin-arm.tar.gz -o google-cloud-cli-382.0.0-darwin-arm.tar.gz
tar -zxvf google-cloud-cli-382.0.0-darwin-arm.tar.gz -C ~/tools
cd ~/tools
./google-cloud-sdk/install.sh

test

1
2
3
4
5
% gcloud --version
Google Cloud SDK 382.0.0
bq 2.0.74
core 2022.04.15
gsutil 5.9

Mac App Store

Reference