How to set up your Mac in an hour

Brew (必要)

Brew 是個套件管理工具。

安裝

安裝的過程,如果缺少 xcode 會提示安裝

1
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

使用 Homebrew Bundle

Dump

dump 已經安裝過的套件

1
brew bundle dump --force

Install

Brewfile 安裝套件

1
brew bundle

範例 Brewfile

我常用的一些工具

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
tap "homebrew/bundle"
tap "homebrew/cask"
tap "homebrew/cask-fonts"
tap "homebrew/core"
brew "ansible"
brew "antigen"
brew "bat"
brew "go"
brew "helm"
brew "htop"
brew "kubernetes-cli"
brew "kubeless"
brew "mycli"
brew "node"
brew "tinc"
brew "tree"
brew "watch"
brew "wget"
brew "yarn"
brew "zsh"
brew "zsh-completions"
cask "alfred"
cask "appcleaner"
cask "docker"
cask "dotnet-sdk"
cask "font-fira-code"
cask "font-sourcecodepro-nerd-font"
cask "google-chrome"
cask "intellij-idea"
cask "istat-menus"
cask "iterm2"
cask "karabiner-elements"
cask "keka"
cask "pock"
cask "rider"
cask "smartgit"
cask "tuntap"
cask "visual-studio-code"

美化 Terminal

我常用的組合

  • iTerm2: 取代原生的 Terminal
  • zsh: 跟 bash 一樣的東西,有很多擴充套件可以用,參考 awesome-zsh-plugins
  • oh-my-zsh: zsh 的一個框架
  • antigen: zsh 的擴充套件管理框架

安裝必要套件

font-fira-code 可以連字

1
2
3
4
brew cask install iterm2
brew install zsh antigen
brew tap homebrew/cask-fonts
brew cask install font-fira-code font-sourcecodepro-nerd-font

設定 zsh 為啟動的 shell

1
2
sudo sh -c "echo $(which zsh) >> /etc/shells"
chsh -s $(which zsh)

設定 iTerm2

iTerm2 的主題是使用 Tomorrow Night Eighties,其他主題可以到這裡找 Iterm2-color-schemes
在 iTerm2 中導入個人設定, 打開 Perference -> Profiles -> Other Actions... -> Import JSON Profiles... -> 選擇要導入的設定

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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
{
"Ansi 3 Color" : {
"Green Component" : 0.80000000000000004,
"Red Component" : 1,
"Blue Component" : 0.40000000000000002
},
"Tags" : [

],
"Ansi 12 Color" : {
"Green Component" : 0.59999999999999998,
"Red Component" : 0.40000000000000002,
"Blue Component" : 0.80000000000000004
},
"Ansi 7 Color" : {
"Green Component" : 0.99997437000274658,
"Red Component" : 1,
"Blue Component" : 0.99999129772186279
},
"Draw Powerline Glyphs" : true,
"Bold Color" : {
"Green Component" : 0.80000000000000004,
"Red Component" : 0.80000000000000004,
"Blue Component" : 0.80000000000000004
},
"Ansi 8 Color" : {
"Green Component" : 0,
"Red Component" : 0,
"Blue Component" : 0
},
"Ansi 9 Color" : {
"Green Component" : 0.46666666670000001,
"Red Component" : 0.94901960780000005,
"Blue Component" : 0.47843137250000001
},
"Horizontal Spacing" : 1,
"Rows" : 25,
"Default Bookmark" : "No",
"Ansi 5 Color" : {
"Green Component" : 0.59999999999999998,
"Red Component" : 0.80000000000000004,
"Blue Component" : 0.80000000000000004
},
"Cursor Guide Color" : {
"Red Component" : 0.70213186740875244,
"Color Space" : "sRGB",
"Blue Component" : 1,
"Alpha Component" : 0.25,
"Green Component" : 0.9268307089805603
},
"Non-ASCII Anti Aliased" : true,
"Use Bright Bold" : true,
"Ansi 10 Color" : {
"Green Component" : 0.80000000000000004,
"Red Component" : 0.59999999999999998,
"Blue Component" : 0.59999999999999998
},
"Ambiguous Double Width" : false,
"Jobs to Ignore" : [
"rlogin",
"ssh",
"slogin",
"telnet"
],
"Ansi 15 Color" : {
"Green Component" : 0.99997437000274658,
"Red Component" : 1,
"Blue Component" : 0.99999129772186279
},
"Foreground Color" : {
"Green Component" : 0.80000000000000004,
"Red Component" : 0.80000000000000004,
"Blue Component" : 0.80000000000000004
},
"Working Directory" : "\/Users\/doggy",
"Blinking Cursor" : true,
"Disable Window Resizing" : true,
"Sync Title" : false,
"Prompt Before Closing 2" : false,
"BM Growl" : true,
"Mouse Reporting" : true,
"Command" : "",
"Description" : "Default",
"Screen" : -1,
"Selection Color" : {
"Green Component" : 0.31764705882352939,
"Red Component" : 0.31764705882352939,
"Blue Component" : 0.31764705882352939
},
"Columns" : 80,
"Idle Code" : 0,
"Ansi 13 Color" : {
"Green Component" : 0.59999999999999998,
"Red Component" : 0.80000000000000004,
"Blue Component" : 0.80000000000000004
},
"Custom Command" : "No",
"ASCII Anti Aliased" : true,
"Non Ascii Font" : "Monaco 12",
"Vertical Spacing" : 1,
"Use Bold Font" : true,
"Option Key Sends" : 0,
"Selected Text Color" : {
"Green Component" : 0.80000000000000004,
"Red Component" : 0.80000000000000004,
"Blue Component" : 0.80000000000000004
},
"Background Color" : {
"Green Component" : 0.1764705882352941,
"Red Component" : 0.1764705882352941,
"Blue Component" : 0.1764705882352941
},
"Character Encoding" : 4,
"Ansi 11 Color" : {
"Green Component" : 0.80000000000000004,
"Red Component" : 1,
"Blue Component" : 0.40000000000000002
},
"Thin Strokes" : 1,
"Use Italic Font" : true,
"Unlimited Scrollback" : false,
"Keyboard Map" : {
"0xf728-0x80000" : {
"Action" : 10,
"Text" : "d"
},
"0xf702-0x280000" : {
"Action" : 10,
"Text" : "b"
},
"0xf70d-0x20000" : {
"Action" : 10,
"Text" : "[21;2~"
},
"0x7f-0x80000" : {
"Action" : 11,
"Text" : "0x1b 0x7f"
},
"0xf708-0x20000" : {
"Action" : 10,
"Text" : "[15;2~"
},
"0x33-0x40000" : {
"Action" : 11,
"Text" : "0x1b"
},
"0xf703-0x260000" : {
"Action" : 10,
"Text" : "[1;6C"
},
"0xf729-0x20000" : {
"Action" : 10,
"Text" : "[1;2H"
},
"0xf702-0x260000" : {
"Action" : 10,
"Text" : "[1;6D"
},
"0x38-0x40000" : {
"Action" : 11,
"Text" : "0x7f"
},
"0xf72b-0x40000" : {
"Action" : 10,
"Text" : "[1;5F"
},
"0xf70c-0x20000" : {
"Action" : 10,
"Text" : "[20;2~"
},
"0xf701-0x260000" : {
"Action" : 10,
"Text" : "[1;6B"
},
"0x32-0x40000" : {
"Action" : 11,
"Text" : "0x00"
},
"0xf707-0x20000" : {
"Action" : 10,
"Text" : "[1;2S"
},
"0xf703-0x240000" : {
"Action" : 10,
"Text" : "[1;5C"
},
"0xf700-0x260000" : {
"Action" : 10,
"Text" : "[1;6A"
},
"0xf702-0x240000" : {
"Action" : 10,
"Text" : "[1;5D"
},
"0xf703-0x300000" : {
"Action" : 11,
"Text" : "0x5"
},
"0x37-0x40000" : {
"Action" : 11,
"Text" : "0x1f"
},
"0x3-0x200000" : {
"Action" : 11,
"Text" : "0xd"
},
"0xf701-0x240000" : {
"Action" : 10,
"Text" : "[1;5B"
},
"0xf702-0x300000" : {
"Action" : 11,
"Text" : "0x1"
},
"0xf703-0x220000" : {
"Action" : 10,
"Text" : "[1;2C"
},
"0xf739-0x0" : {
"Action" : 13,
"Text" : ""
},
"0xf70b-0x20000" : {
"Action" : 10,
"Text" : "[19;2~"
},
"0xf728-0x0" : {
"Action" : 11,
"Text" : "0x4"
},
"0xf706-0x20000" : {
"Action" : 10,
"Text" : "[1;2R"
},
"0xf700-0x240000" : {
"Action" : 10,
"Text" : "[1;5A"
},
"0xf702-0x220000" : {
"Action" : 10,
"Text" : "[1;2D"
},
"0x36-0x40000" : {
"Action" : 11,
"Text" : "0x1e"
},
"0xf70f-0x20000" : {
"Action" : 10,
"Text" : "[24;2~"
},
"0xf701-0x220000" : {
"Action" : 10,
"Text" : "[1;2B"
},
"0xf70a-0x20000" : {
"Action" : 10,
"Text" : "[18;2~"
},
"0xf729-0x40000" : {
"Action" : 10,
"Text" : "[1;5H"
},
"0xf72b-0x20000" : {
"Action" : 10,
"Text" : "[1;2F"
},
"0xf700-0x220000" : {
"Action" : 10,
"Text" : "[1;2A"
},
"0x30-0x200000" : {
"Action" : 12,
"Text" : "0"
},
"0xf705-0x20000" : {
"Action" : 10,
"Text" : "[1;2Q"
},
"0x31-0x200000" : {
"Action" : 12,
"Text" : "1"
},
"0x33-0x200000" : {
"Action" : 12,
"Text" : "3"
},
"0x35-0x40000" : {
"Action" : 11,
"Text" : "0x1d"
},
"0x34-0x200000" : {
"Action" : 12,
"Text" : "4"
},
"0x32-0x200000" : {
"Action" : 12,
"Text" : "2"
},
"0x35-0x200000" : {
"Action" : 12,
"Text" : "5"
},
"0x36-0x200000" : {
"Action" : 12,
"Text" : "6"
},
"0x37-0x200000" : {
"Action" : 12,
"Text" : "7"
},
"0x2d-0x40000" : {
"Action" : 11,
"Text" : "0x1f"
},
"0x38-0x200000" : {
"Action" : 12,
"Text" : "8"
},
"0x2a-0x200000" : {
"Action" : 12,
"Text" : "*"
},
"0x39-0x200000" : {
"Action" : 12,
"Text" : "9"
},
"0x2b-0x200000" : {
"Action" : 12,
"Text" : "+"
},
"0xf70e-0x20000" : {
"Action" : 10,
"Text" : "[23;2~"
},
"0x2e-0x200000" : {
"Action" : 12,
"Text" : "."
},
"0x2d-0x200000" : {
"Action" : 12,
"Text" : "-"
},
"0xf709-0x20000" : {
"Action" : 10,
"Text" : "[17;2~"
},
"0x7f-0x100000" : {
"Action" : 11,
"Text" : "0x15"
},
"0x2f-0x200000" : {
"Action" : 12,
"Text" : "\/"
},
"0xf704-0x20000" : {
"Action" : 10,
"Text" : "[1;2P"
},
"0x34-0x40000" : {
"Action" : 11,
"Text" : "0x1c"
},
"0xf703-0x280000" : {
"Action" : 10,
"Text" : "f"
}
},
"Window Type" : 0,
"Cursor Type" : 2,
"Background Image Location" : "",
"Blur" : false,
"Badge Color" : {
"Red Component" : 1,
"Color Space" : "sRGB",
"Blue Component" : 0,
"Alpha Component" : 0.5,
"Green Component" : 0.1491314172744751
},
"Scrollback Lines" : 1000,
"Send Code When Idle" : false,
"Close Sessions On End" : true,
"Terminal Type" : "xterm-256color",
"Visual Bell" : true,
"Flashing Bell" : false,
"Silence Bell" : false,
"Ansi 14 Color" : {
"Green Component" : 0.80000000000000004,
"Red Component" : 0.40000000000000002,
"Blue Component" : 0.80000000000000004
},
"ASCII Ligatures" : true,
"Name" : "Default",
"Cursor Text Color" : {
"Green Component" : 0.1764705882,
"Red Component" : 0.1764705882,
"Blue Component" : 0.1764705882
},
"Shortcut" : "",
"Cursor Color" : {
"Green Component" : 0.80000000000000004,
"Red Component" : 0.80000000000000004,
"Blue Component" : 0.80000000000000004
},
"Ansi 0 Color" : {
"Green Component" : 0,
"Red Component" : 0,
"Blue Component" : 0
},
"Guid" : "DA94C0E2-635D-4C95-B3D4-4FA2BE019BCE",
"Ansi 1 Color" : {
"Green Component" : 0.46666666666666667,
"Red Component" : 0.94901960784313721,
"Blue Component" : 0.47843137254901957
},
"Link Color" : {
"Red Component" : 0,
"Color Space" : "sRGB",
"Blue Component" : 0.73423302173614502,
"Alpha Component" : 1,
"Green Component" : 0.35916060209274292
},
"Transparency" : 0,
"Ansi 2 Color" : {
"Green Component" : 0.80000000000000004,
"Red Component" : 0.59999999999999998,
"Blue Component" : 0.59999999999999998
},
"Use Non-ASCII Font" : false,
"Ansi 6 Color" : {
"Green Component" : 0.80000000000000004,
"Red Component" : 0.40000000000000002,
"Blue Component" : 0.80000000000000004
},
"Normal Font" : "SauceCodeProNerdFontComplete-Medium 14",
"Custom Directory" : "No",
"Ansi 4 Color" : {
"Green Component" : 0.59999999999999998,
"Red Component" : 0.40000000000000002,
"Blue Component" : 0.80000000000000004
},
"Right Option Key Sends" : 0
}

設定 zsh

zsh 的設定會在根目錄中的 .zshrc
這裡使用的主題是 powerlevel10k, 並且我有把 envaliases 的設定拆開來

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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH

fpath=(~/.zsh/completion $fpath)
autoload -Uz compinit && compinit -i

source <(kubectl completion zsh)

# import antigen
source /usr/local/share/antigen/antigen.zsh

# Load the oh-my-zsh's library.
antigen use oh-my-zsh

# Load theme
antigen theme romkatv/powerlevel10k
ZSH_THEME="powerlevel10k/powerlevel10k"
POWERLEVEL9K_MODE="nerdfont-complete"
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(ssh context dir dir_writable newline os_icon vcs)

# Bundles from the default repo (robbyrussell's oh-my-zsh).
antigen bundle osx
antigen bundle brew
antigen bundle brew-cask
antigen bundle common-aliases
antigen bundle colored-man
antigen bundle extract
antigen bundle git
antigen bundle gitfast
antigen bundle git-extras
antigen bundle safe-paste
antigen bundle docker
antigen bundle docker-compose
antigen bundle rsync
antigen bundle golang
antigen bundle terraform
antigen bundle kubectl

antigen bundle ssh-agent
antigen bundle zsh-users/zsh-autosuggestions
antigen bundle zsh-users/zsh-syntax-highlighting
antigen bundle zsh-users/zsh-completions
antigen bundle unixorn/autoupdate-antigen.zshplugin
antigen bundle zsh-users/zsh-history-substring-search

# Tell antigen that you're done.
antigen apply

# Set list of themes to pick from when loading at random
# Setting this variable when ZSH_THEME=random will cause zsh to load
# a theme from this variable instead of looking in ~/.oh-my-zsh/themes/
# If set to an empty array, this variable will have no effect.
# ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" )

# Uncomment the following line to use case-sensitive completion.
# CASE_SENSITIVE="true"

# Uncomment the following line to use hyphen-insensitive completion.
# Case-sensitive completion must be off. _ and - will be interchangeable.
# HYPHEN_INSENSITIVE="true"

# Uncomment the following line to disable bi-weekly auto-update checks.
# DISABLE_AUTO_UPDATE="true"

# Uncomment the following line to automatically update without prompting.
# DISABLE_UPDATE_PROMPT="true"

# Uncomment the following line to change how often to auto-update (in days).
# export UPDATE_ZSH_DAYS=13

# Uncomment the following line if pasting URLs and other text is messed up.
# DISABLE_MAGIC_FUNCTIONS=true

# Uncomment the following line to disable colors in ls.
# DISABLE_LS_COLORS="true"

# Uncomment the following line to disable auto-setting terminal title.
# DISABLE_AUTO_TITLE="true"

# Uncomment the following line to enable command auto-correction.
# ENABLE_CORRECTION="true"

# Uncomment the following line to display red dots whilst waiting for completion.
# COMPLETION_WAITING_DOTS="true"

# Uncomment the following line if you want to disable marking untracked files
# under VCS as dirty. This makes repository status check for large repositories
# much, much faster.
# DISABLE_UNTRACKED_FILES_DIRTY="true
# Uncomment the following line if you want to change the command execution time
# stamp shown in the history command output.
# You can set one of the optional three formats:
# "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
# or set a custom format using the strftime function format specifications,
# see 'man strftime' for details.
# HIST_STAMPS="mm/dd/yyyy"

# Would you like to use another custom folder than $ZSH/custom?
# ZSH_CUSTOM=/path/to/new-custom-folder

# Which plugins would you like to load?
# Standard plugins can be found in ~/.oh-my-zsh/plugins/*
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
# plugins=(git zsh-syntax-highlighting zsh-autosuggestions docker docker-compose brew rsync go terraform)

# User configuration

# export MANPATH="/usr/local/man:$MANPATH"

# You may need to manually set your language environment
# export LANG=en_US.UTF-8
[ -f ~/.zsh_env ] && source ~/.zsh_env
[ -f ~/.zsh_aliases ] && source ~/.zsh_aliases

# Preferred editor for local and remote sessions
# if [[ -n $SSH_CONNECTION ]]; then
# export EDITOR='vim'
# else
# export EDITOR='mvim'
# fi

# Compilation flags
# export ARCHFLAGS="-arch x86_64"

# Set personal aliases, overriding those provided by oh-my-zsh libs,
# plugins, and themes. Aliases can be placed here, though oh-my-zsh
# users are encouraged to define aliases within the ZSH_CUSTOM folder.
# For a full list of active aliases, run `alias`.
#
# Example aliases
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"

# ignore ctrl+d close session
set -o ignoreeof
# export IGNOREEOF=10

# zsh parameter completion for the dotnet CLI

_dotnet_zsh_complete()
{
local completions=("$(dotnet complete "$words")")

reply=( "${(ps:\n:)completions}" )
}

compctl -K _dotnet_zsh_complete dotnet

bindkey '^[[A' history-substring-search-up
bindkey '^[[B' history-substring-search-down
1
2
3
4
5
6
7
# tool aliases
alias cat=bat
alias nano=vim

# quick open rc
alias vimrc='${=EDITOR} ~/.vimrc'
alias myclirc='${=EDITOR} ~/.myclirc'
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# Path
export PATH=/usr/local/sbin:$PATH

# Go
export GOPATH=~/go
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
#export GO111MODULE=on

# Etcd
export ETCDCTL_API=3

# Editor
export EDITOR=vim

# Python
export PATH=/usr/local/opt/python/libexec/bin:$PATH

# Latex
export PATH=/Library/TeX/texbin:$PATH

常用工具

套件管理工具

  • Brew: macOS 缺少套件的管理工具

SDKs

IDEs

生產力工具

  • mycli: 好用版的 mysql cli
  • karabiner: 自定義鍵盤快捷鍵、按鍵、巨集
  • istat: 在 menu bar 顯示各式各樣的資訊
  • alfred: 強化版 Spotlight
  • Latex: 寫文件用的

通用工具

字型