Macbook 開發環境設定大全

Photo by Ben Kolde on Unsplash

Overview

Ref: [[2022-09-10-ipad-setup]]

Challenges 現況 挑戰

  • 每次要設定 macbook 開發環境時, 總是頭痛到底設定了哪些東西跟軟體

Objectives 目標 效益

  • 整理開發環境所需的套件與安裝指令, 方便後續新增查找

KRs 結果 解法

  • 2022-09-10 設定完成
  • 2022-09-17 重置 MacBook Pro 2019 15" i7 16G/256G

Software 軟體

Dev 開發

  • IDE, Editor: Xcode, vscode, sublime text, iTerm2, Fig
  • CI/CD: git, Sourcetree
  • Dev: Python, docker, postman

Office

  • Utils: xtrafinder
 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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# Productivity 
brew install --cask brave-browser # brave browser
brew install --cask miro    # miro
brew install --cask canva   # canva
brew install --cask raycast # launcher + emoji + ...
brew install --cask skitch  # Screen capture tool
brew install --cask clipy   # copy paste list
brew install --cask rectangle   # shortcut to move app windows
brew install --cask cheatsheet  # show shortcut for app
brew install --cask karabiner-elements  # Keyboard customizer
brew install --cask bettertouchtool     # customize input. "GoldenChaos-BTT"
brew install --cask background-music    # Record system audio with QuickTime

open https://sparkmailapp.com/  # Spark Email
open https://dropoverapp.com/   # Dropover. Drag & drop
open https://www.focustodo.cn/  # focus-todo pomodoro
open https://giphy.com/apps/giphycapture # GIPHY Capture. The GIF Maker
open https://apps.apple.com/tw/app/picsew-滾動截圖和長圖拼接/id1208145167  # Picsew. 滾動截圖和長圖拼接
open https://apps.apple.com/en/app/hiwater-饮水金字塔/id1561732866

# Language
brew install --cask deepl

# Dev
brew install --cask visual-studio-code
brew install --cask sublime-text
brew install --cask postman   # API platform
brew install --cask transmit  # FTP

# Collaborate
brew install --cask zoom
brew install --cask skype
brew install --cask discord
brew install --cask slack

# Utils
brew install --cask flux    # Screen color temperature controller
brew install --cask mounty  # Re-mounts write-protected NTFS volumes
brew install --cask hiddenbar   # Hide status bar icons
brew install --cask tunnelbear  # VPN client
# brew install --cask aldente   # limit maximum charging
brew install --cask appcleaner  # uninstall unwanted apps
brew install --cask coconutbattery  # Batteries history
brew install --cask keepingyouawake # Prevent sleep mode
# brew install --cask the-unarchiver  # Unpacks archive files

# Image
brew install --cask imageoptim  # compress images

# Video, Editing 剪輯, 轉檔
brew install --cask macx-video  # video processing 
brew install --cask vlc   # media player
open https://www.movavi.com/  # Movavi 

# Music
open https://apps.apple.com/us/app/speakline-text-to-speech/id441968334?mt=12   # SpeakLine - Text to Speech

# Docs
open https://bear.app/  # Markdown Notes for iPhone, iPad, MacOS
open https://apps.apple.com/mo/app/craft-文件與記錄編輯器/id1487937127  # Craft docs editor

# Screen Recording 螢幕錄影
open https://www.screencastify.com/ # Screencastify - Screen Video Recorder. Export 網頁 標記
open https://obsproject.com/  # OBS 全螢幕
open https://www.loom.com/    # Loom: Async Video Messaging for Work. Online only
open https://www.iorad.com/   # iorad - the tutorial builder. 截圖步驟投影片 Online only

# 字幕
open https://otter.ai/  # Otter.ai - Voice Meeting Notes & Real-time Transcription

Other Mac Setups

  • Trackpad, Accessibility > Pointer Control, Trackpad Options > Enabling Dragging (three finger drag)
  • Keyboard > Shortcuts
    • Input Source: cmd ⌘ + space. 與 spotlight 互換 ctrl ⌃ + space
  • Sharing (Computer Name), Dock (Left)
  • Batter > Battery > disable “Automatic graphics swithting”

Home Folder Structure

1
2
3
4
5
# ~/
dev
  andro
  env
Downloads  

homebrew - macOS 套件管理工具

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
# install homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# Run these two commands in your terminal to add Homebrew to your PATH:
# 如果是 M1 的話需要加以下兩個 command. Intel 的不用, /usr/local 本來就在 PATH 了
# https://stackoverflow.com/questions/70983104/brew-installs-not-appearing-in-usr-local-bin
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"

brew update 
brew upgrade

# https://github.com/Homebrew/brew/issues/3784
# use commands below if you want to delete downloaded caches in ~/Library/Caches/Homebrew
# brew cleanup -n
# brew cleanup
# rm -rf $(brew --cache)

iTerm2 - 點亮 Terminal + Alfred + Fig

iTerm2 shortcuts

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
# iTerm2: replacement for Terminal
brew install --cask iterm2

### fig: IDE-style autocomplete for your existing terminal
brew install --cask fig

# Setup shortcuts
# ⌘ ← "SEND HEX CODE" 0x01
# ⌘ → "SEND HEX CODE" 0x05
# ⌥ ← "SEND ESC SEQ"  b
# ⌥ → "SEND ESC SEQ"  f

# iTerm2 > Preferences > Keys > Key Bindings
  • Themes: Nord, JetBrains Darcula, tokyonight-storm

1. zsh

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
# 用 homebrew 安裝的 zsh 位置在 /usr/local/bin/zsh
which zsh
# > /bin/zsh
zsh --version
# > zsh 5.8.1 (x86_64-apple-darwin21.0)

brew install zsh
sudo sh -c "echo $(which zsh) >> /etc/shells"
chsh -s $(which zsh)
# restart terminal
which zsh
# > (Intel) /usr/local/bin/zsh
# > (M1) /opt/homebrew/bin/zsh
zsh --version
# > zsh 5.9 (arm-apple-darwin21.3.0)

2. oh-my-zsh: zsh setup management framework

  • 下次再試試看也用 Fig 安裝 oh-my-zsh
  • 不使用 fig 安裝 oh-my-zsh, 仍然使用下列 command
1
2
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
# vim ~/.zshrc

3. Nerd font: font package

1
2
3
4
5
6
7
# Nerd font
brew tap homebrew/cask-fonts
brew install --cask font-hack-nerd-font
 
# 為了稍後的 p10k 設定, 要讓 icon 能正常顯示
# iTerm2 > Preferences > Profile > Text > Font > 選 Hack Nerd Font Mono
# https://github.com/romkatv/powerlevel10k/issues/996

4. Powerlevel10k: oh-my-zsh Themes

1
2
3
4
5
# Powerlevel10k
brew install powerlevel10k
echo "source $(brew --prefix)/share/powerlevel10k/powerlevel10k.zsh-theme" >>~/.zshrc
source ~/.zshrc
p10k configure

5. zsh plugins 改用 Fig 安裝 Plugins

Note: 這一塊我在弄的時候有點搞砸了… 但總之最後是通了, 之後有機會 (x) 再回來修

=> 2022-09-17 改先裝 fig (因為 fig 裡也有這些 package), 就不用敲這些指令了! 而且可以用帳號同步, 太方便了

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
git clone --depth 1 -- https://github.com/marlonrichert/zsh-snap.git
source zsh-snap/install.zsh
znap pull
echo "znap source marlonrichert/zsh-autocomplete" >> ~/.zshrc

# https://github.com/zsh-users/zsh-autosuggestions/blob/master/INSTALL.md#oh-my-zsh
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
git clone --depth 1 -- https://github.com/marlonrichert/zsh-autocomplete.git $ZSH_CUSTOM/plugins/zsh-autocomplete

vi ~/.zshrc
# plugins=(git zsh-autosuggestions zsh-autocomplete)

# brew install zsh-autosuggestions
# echo "source $(brew --prefix)/share/zsh-autosuggestions/zsh-autosuggestions.zsh" >> ~/.zshrc 

VS Code 設定 p10k terminal

  • Preferences: Open User Settings JSON (cmd ⌘ + shift + P) 加入以下:
1
2
3
"terminal.external.osxExec": "iTerm2.app",
"terminal.integrated.defaultProfile.osx": "zsh",
"terminal.integrated.fontFamily": "Hack Nerd Font Mono"

vscode extentions

git - 版本控制

1
2
3
4
5
6
# Version control
brew install git
brew install --cask sourcetree

git config --global user.email "[email protected]"
git config --global user.name "androchentw"

python

pyenv + pyenv-virtualenv

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
# This is the recommended method of installation if you installed pyenv with Homebrew.
brew install pyenv-virtualenv
echo 'if which pyenv-virtualenv-init > /dev/null; then eval "$(pyenv virtualenv-init -)"; fi' >> ~/.zshrc

brew install pyenv
alias brew='env PATH="${PATH//$(pyenv root)\/shims:/}" brew'

echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.zshrc
echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.zshrc
echo 'eval "$(pyenv init -)"' >> ~/.zshrc
source ~/.zshrc
exec "$SHELL"

pyenv --version
# > pyenv 2.3.4
pyenv-virtualenv --version
# > /usr/local/bin/pyenv-virtualenv: line 106: pyenv-version-name: command not found
# > /usr/local/bin/pyenv-virtualenv: line 141: pyenv-prefix: command not found
# > pyenv-virtualenv 1.1.5 (virtualenv unknown)

python3 + pip3

 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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
which python3
# /usr/bin/python3
python3 --version
# Python 3.8.9
# Python 3.9.6
pip3 --version
# pip 20.2.3 from /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages/pip (python 3.8)
# pip 21.2.4 from /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/site-packages/pip (python 3.9)
which pip3
# /usr/bin/pip3

pyenv install --list | grep " 3\.[1]" 
pyenv install 3.10.7 

pyenv global 3.10.7
# restart iTerm2
python3 --version
# Python 3.10.7
pyenv virtualenv 3.10.7 env-3.10.7

# test env-3.10.7 virtualenv settings
mkdir test 
cd test 
pyenv local env-3.10.7
python --version
# Python 3.10.7
cd ..
rm -rf test


brew install python3
# restart iTerm2

which python3
# /Users/androchentw/.pyenv/shims/python3
which pip3
# /Users/androchentw/.pyenv/shims/pip3
pip3 --version
# pip 22.2.1 from /Users/androchentw/.pyenv/versions/3.10.6/lib/python3.10/site-packages/pip (python 3.10)
which python
# /Users/androchentw/.pyenv/shims/python
which pip
# /Users/androchentw/.pyenv/shims/pip
pip --version
# pip 22.2.1 from /Users/androchentw/.pyenv/versions/3.10.6/lib/python3.10/site-packages/pip (python 3.10)

==> /usr/bin occurs before /usr/local/bin This means that system-provided programs will be used instead of those provided by Homebrew. This is an issue if you eg. brew > installed Python.

Consider editing your .bash_profile to put: /usr/local/bin ahead of /usr/bin in your > $PATH.

Backup shell .rc settings

1
2
cat ~/.zshrc > ~/Downloads/2022-andro.zshrc
cat ~/.p10k.zsh > ~/Downloads/2022-andro.p10k.zsh

Others

sh

Rewritten in Rust: Modern Alternatives of Command-Line Tools

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
brew install nushell
brew install bat
brew install fd
brew install exa
brew install procs
brew install dust
brew install tokei
brew install tealdeer

brew install starship
## Setup startship
nu
# Add the following to the end of your Nushell env file (find it by running $nu.env-path in Nushell):
mkdir ~/.cache/starship
starship init nu | save ~/.cache/starship/init.nu

And add the following to the end of your Nushell configuration (find it by running $nu.config-path):
source ~/.cache/starship/init.nu

Murmur


其他相關