目录

Mac开发环境搭建

翻墙

下载 ShadowsocksX-NG 客户端,配置好服务器。打开 https://google.com/ 测试代理生效。

在执行以下安装命令时,如果新开的shell,先为shell设置代理:

1
export http_proxy=http://127.0.0.1:1087;export https_proxy=http://127.0.0.1:1087;

Xcode Command Line Tools

打开终端,执行

1
xcode-select --install

Homebrew

安装 Homebrew

打开终端,执行

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

更新:

1
2
3
brew update
brew upgrade
brew install mas

brew bundle

通过 brew bundle dump 可以在当前目录导出一个 Brewfile 文件,包含了 tap、brew、cask 和 mas 等内容。

将下面的内容写入到 Brewfile 文件中,并执行 brew bundle 命令导入。

 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
tap "homebrew/bundle"
tap "homebrew/cask"
tap "homebrew/cask-drivers"
tap "homebrew/cask-fonts"
tap "homebrew/cask-versions"
tap "homebrew/core"
tap "homebrew/services"
brew "autojump"
brew "openssl"
brew "sqlite"
brew "python"
brew "flake8"
brew "git"
brew "go"
brew "htop"
brew "httpie"
brew "ipython"
brew "mas"
brew "mongodb", restart_service: true
brew "nginx"
brew "nmap"
brew "pipenv"
brew "postgresql"
brew "pyenv"
brew "redis", restart_service: true
brew "siege"
brew "swig"
brew "tree"
brew "you-get"
brew "zsh"
cask "android-file-transfer"
cask "android-platform-tools"
cask "charles"
cask "cheatsheet"
cask "chromedriver"
cask "docker"
cask "etcher"
cask "fliqlo"
cask "folx"
cask "font-fira-code"
cask "font-mononoki"
cask "font-source-code-pro"
cask "github"
cask "google-chrome"
cask "gqrx"
cask "iina"
cask "iterm2"
cask "laplock"
cask "logitech-options"
cask "microsoft-remote-desktop-beta"
cask "monitorcontrol"
cask "ngrok"
cask "omnigraffle"
cask "postman"
cask "robo-3t"
cask "sequel-pro"
cask "skype"
cask "tunnelblick"
cask "typora"
cask "virtualbox"
cask "visual-studio-code"
cask "wechatwebdevtools"
cask "wireshark"
cask "yyets"
mas "QQ", id: 451108668
mas "QQ音乐", id: 595615424
mas "Reeder", id: 880001334
mas "The Unarchiver", id: 425424353
mas "Xcode", id: 497799835
mas "微信", id: 836500024
mas "截图", id: 1059334054
mas "熊掌记", id: 1091189122
mas "网易云音乐", id: 944848654
mas "钉钉", id: 1435447041

oh-my-zsh

安装 oh-my-zsh

1
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

配置 oh-my-zsh

编辑~/.zshrc文件:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# 以下是修改已经存在的配置
ZSH_THEME="agnoster"
plugins=(git osx autojump sublime docker)
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8

# 新增配置
DEFAULT_USER="yourusername"

export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8

mas

mas 用来管理 Mac App Store Applications。

安装 mas

1
brew install mas

常用操作

常用操作与brew基本一致。

1
2
3
4
mas search <keyword>
mas install <ID1> <ID2>
mas upgrade <ID1> <ID2>
mas outdated

常用 App

  • 836500024 WeChat (2.3.10)
  • 497799835 Xcode (9.2)
  • 409183694 Keynote (7.3.1)
  • 451108668 QQ (6.3.1)
  • 944848654 NeteaseMusic (1.5.9)
  • 截图
  • Bear
  • Reeder

配置

.zshrc

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
# brew
export PATH=/usr/local/sbin:$HOME/bin:$PATH

# proxy
alias pip="pip3 --proxy 127.0.0.1:1087"
alias ss="export http_proxy=http://127.0.0.1:1087;export https_proxy=http://127.0.0.1:1087;"
alias unss="unset http_proxy;unset https_proxy;"

# quick open
alias md="open -a Typora"
alias idle="idle3 -c 'from pprint import pprint;import datetime,time,os,sys,json,collections,math;'"

# pipenv
alias v="pipenv shell"
export PIPENV_VENV_IN_PROJECT=true

# ssh alias
alias pi="ssh [email protected] -p 3154"

vim

下载 solarized 主题配色

1
2
3
mkdir -p ~/.vim/colors
cd ~/.vim/colors
curl -O https://raw.githubusercontent.com/altercation/vim-colors-solarized/master/colors/solarized.vim
1
vi ~/.vimrc
1
2
3
4
syntax on
set background=dark
colorscheme solarized
set number

.gitconfig

1
2
3
4
5
[user]
	name = foo
	email = [email protected]
[core]
	quotepath = false

quotepath = false 可以使 shell 中的 git 能够显示中文路径和文件名。

Typora

主题:Solarized

iTerm2

  • non-ASCII字体选用 mononoki,Horizontal 90%,Vertical 110%;
  • Preferences - Profiles - Colors - Color Presets,修改配色主题为 Solarized Dark
  • Preferences - Keys - Hotkey - Hotkey toggles a dedicated window with profile 勾选;
  • Preferences - Profiles - Text - Text Rendering - Draw bold text in bright colors 取消勾选;

Sublime

插件

  • Package Control
  • AdvancedNewFile
  • GitGutter
  • Theme - One Dark
  • nginx
  • HTML-CSS-JS Prettify

配置

 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
{
	"bold_folder_labels": true,
	"color_scheme": "Packages/Theme - One Dark/One Dark.tmTheme",
	"debounce_delay": 10,
	"default_line_ending": "unix",
	"detect_indentation": false,
	"draw_minimap_border": true,
	"ensure_newline_at_eof_on_save": true,
	"fade_fold_buttons": false,
	"file_exclude_patterns":
	[
		"*.pyc",
		"*.pyo",
		"*.exe",
		"*.dll",
		"*.obj",
		"*.o",
		"*.a",
		"*.lib",
		"*.so",
		"*.dylib",
		"*.ncb",
		"*.sdf",
		"*.suo",
		"*.pdb",
		"*.idb",
		".DS_Store",
		"*.class",
		"*.psd",
		"*.db",
		"*.sublime-workspace",
		".DS_Store"
	],
	"folder_exclude_patterns":
	[
		".svn",
		".git",
		".hg",
		"CVS",
		"venv",
        ".venv",
		".idea",
		"__pycache__",
        ".pytest_cache"
	],
	"font_face": "Source Code Pro",
	"font_size": 16,
	"highlight_line": true,
	"hot_exit": true,
	"ignored_packages":
	[
		"Vintage"
	],
	"line_padding_bottom": 1,
	"line_padding_top": 2,
	"rulers":
	[
		80,
		100,
		120
	],
	"save_on_focus_lost": true,
	"scroll_past_end": true,
	"show_encoding": true,
	"theme": "One Dark.sublime-theme",
	"translate_tabs_to_spaces": true,
	"trim_trailing_white_space_on_save": true,
	"word_wrap": true
}

Python Snippets

snippets存储路径为 ~/Library/Application Support/Sublime Text 3/Packages/User

snippets扩展名为 .sublime-snippet

1
cd ~/Library/Application Support/Sublime Text 3/Packages/User
1
vi coding.sublime-snippet
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
<snippet>
    <content><![CDATA[
# coding=utf-8

]]></content>
    <!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
    <tabTrigger>enc</tabTrigger>
    <!-- Optional: Set a scope to limit where the snippet will trigger -->
    <scope>source.python</scope>
</snippet>
1
vi shebang.sublime-snippet
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
<snippet>
    <content><![CDATA[
#!/usr/bin/env python3

]]></content>
    <!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
    <tabTrigger>env</tabTrigger>
    <!-- Optional: Set a scope to limit where the snippet will trigger -->
    <scope>source.python</scope>
</snippet>

VSCode

扩展列表,通过 code --list-extensions 导出。

1
2
3
4
5
6
7
8
9
CoenraadS.bracket-pair-colorizer
eamodio.gitlens
hangxingliu.vscode-nginx-conf-hint
mikestead.dotenv
ms-azuretools.vscode-docker
ms-python.python
ms-vscode.Go
PKief.material-icon-theme
zhuangtongfa.Material-theme

通过 code install-extension 扩展 来安装。

FAQ

卸载oh-my-zsh

1
uninstall_oh_my_zsh

Ubuntu上安装oh-my-zsh依赖

1
2
3
4
5
6
sudo apt update
sudo apt upgrade

sudo apt install zsh
sudo apt install git
sudo apt install autojump

Ubuntu启用agnoster主题报错

  • 报错:character not in range
  • 原因:Ubuntu主机没有正确设置locale,至少应包含一项UTF-8的locale。
  • 解决:
    • 检查locale,localelocale -a命令;
    • 重新生成locale,在/etc/locale.gen中取消注释,然后执行locale-gen命令;