还在用 Win?教你从零把 Mac 打造成开发利器
本文作者:guoweiye,騰訊 PCG 開發(fā)工程師
很多人都說 Mac 比 Windows 更適合做開發(fā),那關(guān)鍵是要把 Mac 配置好,下面就來和大家分享一下如何從零開始把一臺(tái)新 Mackbook 打造成開發(fā)利器。
一、基本設(shè)置
升級(jí)操作系統(tǒng)(macOS Mojave 10.14.3)
關(guān)閉菜單欄效果, 減少資源占用和產(chǎn)生的熱量
系統(tǒng)偏好設(shè)置/輔助功能/顯示, 勾選 (減弱動(dòng)態(tài)效果、減少透明度)
配置睡眠保護(hù)
系統(tǒng)偏好設(shè)置/安全性與隱私/通用, 勾選(進(jìn)入睡眠或開始保護(hù)程序 立即 要求輸入密碼)
配置觸發(fā)角
系統(tǒng)偏好設(shè)置/屏幕保護(hù)程序/觸發(fā)角, 選擇(右上桌面,左下啟動(dòng)臺(tái),右下啟動(dòng)屏幕保護(hù))
二、工具安裝
Xcode Command Line Tools
xcode-select --install
Homebrew
/usr/bin/ruby?-e?"$(curl?-fsSL?https://raw.githubusercontent.com/Homebrew/install/master/install
brew cask list
brew 安裝常用工具
brew cask 安裝常用工具
其他工具
下載工具 motrix
截圖工具 jietu
看圖工具 jietu
brew cask tools list
快速查看工具 Nicer plugins for QuickLook
brew cask install qlcolorcode qlstephen qlmarkdown quicklook-json qlimagesize webpquicklook suspicious-package quicklookase qlvideo
微軟的字體 Consolas
??wget?-qO-?https://raw.githubusercontent.com/yakumioto/YaHei-Consolas-Hybrid-1.12/master/install.sh?&&?sudo?install.shszrz插件
graphviz 所用語言 dot 驗(yàn)證
dot -h
三、其他配置
設(shè)置 iterm2
iterm2 配色官網(wǎng)
iterm2 > preference > profiles > colors > Color Presets > solarized dark
????2.安裝 zsh,oh-my-zsh
#?安裝?zsh?及?補(bǔ)全brew?install?zsh?zsh-completions
#?安裝?oh-my-zsh
curl?-L?https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh?|?sh
#?編輯?/etc/shells
sudo?vim?/etc/shells
#?添加?zsh
/usr/local/bin/zsh
#?修改默認(rèn)shell
sudo?chsh?-s?/usr/local/bin/zsh
#?將環(huán)境變量移到~/.env.sh
vim?~/.zshrc
#?設(shè)置主題
ZSH_THEME=pygmalion
#?設(shè)置插件
plugins=(git?colored-man?colorize?github?jira?vagrant?virtualenv?pip?python?brew?osx?zsh-syntax-highlighting)
#?ls?配色生效
unset?LSCOLORS
export?CLICOLOR=1
export?CLICOLOR_FORCE=1
#?生效
source?~/.env.sh
????3. solarized 主題配色
#?clone?之git?clone?https://github.com/altercation/solarized
#?配置?vim?主題
cd?solarized/vim-colors-solarized/
mkdir?-p?~/.vim/colors
cp?colors/solarized.vim?~/.vim/colors/
#?配置?vim
vim?~/.vimrc
syntax?on
set?background=dark
colorscheme?solarized
set?backspace=2
????4. vscode 配置命令行中打開
Open the Command Palette ( ?? P) and type 'shell command' to find the Shell Command: Install 'code' command in PATH command.
vscode 插件安裝
Chinese language pack(中文語言包)
markdownlint(markdown格式檢查器)
atom one dark theme(ATOM 風(fēng)格主題)
one dark pro(主題)
material theme(主題)
vscode-icons(圖標(biāo))
python(vscode python擴(kuò)展包)
go(go 擴(kuò)展包)
????6. vscode shell 選擇,zsh
首選項(xiàng)/設(shè)置, 搜索 terminal.integrated.shell.osx ,設(shè)置值為 /usr/local/bin/zsh
vscode python 解釋器選擇
??P, 搜索 select interpreter ,選擇一個(gè) env-3.6.8
vscode python lint 安裝,選擇 pylint 即可
vscode python 自動(dòng)格式化
"python.formatting.provider": "black"
python 開發(fā)工具
jetbrains 全家桶
pycharm Community
idea Community
四、 python 環(huán)境
pyenv 安裝
#?安裝?pyenv?參考,?http://einverne.github.io/post/2017/04/pyenv.htmlcurl?-L?https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer?|?bash
#?添加環(huán)境變量
vim?~/.zshrc
export?PATH="/.pyenv/bin:<annotation?encoding="application style="font-size: inherit;line-height: 1.75;color: rgb(80, 161, 79);overflow-wrap: inherit !important;word-break: inherit !important;" span="" class="hljs-string" encoding=""application"><span?class="katex-html"?aria-hidden="true" style="font-size: inherit;color: inherit;line-height: 1.75;overflow-wrap: inherit !important;word-break: inherit !important;"><span?class="strut"?style="height:1em;vertical-align:-0.25em;" style="font-size: inherit;color: inherit;line-height: 1.75;overflow-wrap: inherit !important;word-break: inherit !important;"><span?class="mord?mathit"?style="margin-right:0.08125em;" style="font-size: inherit;color: inherit;line-height: 1.75;overflow-wrap: inherit !important;word-break: inherit !important;">H<span?class="mord?mathit"?style="margin-right:0.02778em;" style="font-size: inherit;color: inherit;line-height: 1.75;overflow-wrap: inherit !important;word-break: inherit !important;">O<span?class="mord?mathit"?style="margin-right:0.10903em;" style="font-size: inherit;color: inherit;line-height: 1.75;overflow-wrap: inherit !important;word-break: inherit !important;">M<span?class="mord?mathit"?style="margin-right:0.05764em;" style="font-size: inherit;color: inherit;line-height: 1.75;overflow-wrap: inherit !important;word-break: inherit !important;">E/.<span?class="mord?mathit" style="font-size: inherit;color: inherit;line-height: 1.75;overflow-wrap: inherit !important;word-break: inherit !important;">p<span?class="mord?mathit"?style="margin-right:0.03588em;" style="font-size: inherit;color: inherit;line-height: 1.75;overflow-wrap: inherit !important;word-break: inherit !important;">y<span?class="mord?mathit" style="font-size: inherit;color: inherit;line-height: 1.75;overflow-wrap: inherit !important;word-break: inherit !important;">e<span?class="mord?mathit" style="font-size: inherit;color: inherit;line-height: 1.75;overflow-wrap: inherit !important;word-break: inherit !important;">n<span?class="mord?mathit"?style="margin-right:0.03588em;" style="font-size: inherit;color: inherit;line-height: 1.75;overflow-wrap: inherit !important;word-break: inherit !important;">v/<span?class="mord?mathit" style="font-size: inherit;color: inherit;line-height: 1.75;overflow-wrap: inherit !important;word-break: inherit !important;">b<span?class="mord?mathit" style="font-size: inherit;color: inherit;line-height: 1.75;overflow-wrap: inherit !important;word-break: inherit !important;">i<span?class="mord?mathit" style="font-size: inherit;color: inherit;line-height: 1.75;overflow-wrap: inherit !important;word-break: inherit !important;">n<span?class="mspace"?style="margin-right:0.2777777777777778em;" style="font-size: inherit;color: inherit;line-height: 1.75;overflow-wrap: inherit !important;word-break: inherit !important;">:PATH"
eval?"¨E45E)"eval"(pyenv?init?-)"
eval?"</span?class="mspace"?style="margin-right:0.2777777777777778em;"></span?class="mord?mathit"></span?class="mord?mathit"></span?class="mord?mathit"></span?class="mord?mathit"?style="margin-right:0.03588em;"></span?class="mord?mathit"></span?class="mord?mathit"></span?class="mord?mathit"?style="margin-right:0.03588em;"></span?class="mord?mathit"></span?class="mord?mathit"?style="margin-right:0.05764em;"></span?class="mord?mathit"?style="margin-right:0.10903em;"></span?class="mord?mathit"?style="margin-right:0.02778em;"></span?class="mord?mathit"?style="margin-right:0.08125em;"></span?class="strut"?style="height:1em;vertical-align:-0.25em;"></span?class="katex-html"?aria-hidden="true"></annotation?encoding="application><span?class="katex-html"?aria-hidden="true" style="font-size: inherit;color: inherit;line-height: 1.75;overflow-wrap: inherit !important;word-break: inherit !important;"><span?class="strut"?style="height:1em;vertical-align:-0.25em;" style="font-size: inherit;color: inherit;line-height: 1.75;overflow-wrap: inherit !important;word-break: inherit !important;">(<span?class="mord?mathit" style="font-size: inherit;color: inherit;line-height: 1.75;overflow-wrap: inherit !important;word-break: inherit !important;">p<span?class="mord?mathit"?style="margin-right:0.03588em;" style="font-size: inherit;color: inherit;line-height: 1.75;overflow-wrap: inherit !important;word-break: inherit !important;">y<span?class="mord?mathit" style="font-size: inherit;color: inherit;line-height: 1.75;overflow-wrap: inherit !important;word-break: inherit !important;">e<span?class="mord?mathit" style="font-size: inherit;color: inherit;line-height: 1.75;overflow-wrap: inherit !important;word-break: inherit !important;">n<span?class="mord?mathit"?style="margin-right:0.03588em;" style="font-size: inherit;color: inherit;line-height: 1.75;overflow-wrap: inherit !important;word-break: inherit !important;">v<span?class="mord?mathit" style="font-size: inherit;color: inherit;line-height: 1.75;overflow-wrap: inherit !important;word-break: inherit !important;">i<span?class="mord?mathit" style="font-size: inherit;color: inherit;line-height: 1.75;overflow-wrap: inherit !important;word-break: inherit !important;">n<span?class="mord?mathit" style="font-size: inherit;color: inherit;line-height: 1.75;overflow-wrap: inherit !important;word-break: inherit !important;">i<span?class="mord?mathit" style="font-size: inherit;color: inherit;line-height: 1.75;overflow-wrap: inherit !important;word-break: inherit !important;">t¨<span?class="mord?mathit"?style="margin-right:0.05764em;" style="font-size: inherit;color: inherit;line-height: 1.75;overflow-wrap: inherit !important;word-break: inherit !important;">E45<span?class="mord?mathit"?style="margin-right:0.05764em;" style="font-size: inherit;color: inherit;line-height: 1.75;overflow-wrap: inherit !important;word-break: inherit !important;">E)"<span?class="mord?mathit" style="font-size: inherit;color: inherit;line-height: 1.75;overflow-wrap: inherit !important;word-break: inherit !important;">e<span?class="mord?mathit"?style="margin-right:0.03588em;" style="font-size: inherit;color: inherit;line-height: 1.75;overflow-wrap: inherit !important;word-break: inherit !important;">v<span?class="mord?mathit" style="font-size: inherit;color: inherit;line-height: 1.75;overflow-wrap: inherit !important;word-break: inherit !important;">a<span?class="mord?mathit"?style="margin-right:0.01968em;" style="font-size: inherit;color: inherit;line-height: 1.75;overflow-wrap: inherit !important;word-break: inherit !important;">l"(pyenv?virtualenv-init?-)"
#?常用命令
#?查看可用版本
pyenv?install?-l
#?安裝?python2?最新版本
pyenv?install?2.7.16
#?安裝報(bào)錯(cuò)?ERROR:?The?Python?zlib?extension?was?not?compiled.?Missing?the?zlib??https://github.com/pyenv/pyenv/wiki/common-build-problems
brew?install?readline?xz
#?When?running?Mojave?or?higher?(10.14+)?you?will?also?need?to?install?the?additional?SDK?headers?by?downloading?them?from?Apple?Developers.?You?can?also?check?under?/Library/Developer/CommandLineTools/Packages/?as?some?versions?of?Mac?OS?will?have?the?pkg?locally.
sudo?installer?-pkg?/Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg?-target?/
#?安裝?python3?最新版本?3.7.2
#?報(bào)錯(cuò)?ERROR:?The?Python?ssl?extension?was?not?compiled.?Missing?the?OpenSSL?lib?
#?https://github.com/pyenv/pyenv/issues/1184#issuecomment-409320318
CONFIGURE_OPTS="--with-openssl=$(brew?--prefix?openssl)"?pyenv?install?3.7.2
#?安裝?python?3.6?,tf?支持的最新版本
pyenv?install?3.6.8
#?安裝?python2?最新版?2.7.16
pyenv?install?2.7.16
#?創(chuàng)建虛擬環(huán)境
pyenv?virtualenv?3.6.4?env-3.6.4
#?激活虛擬環(huán)境
pyenv?activate?env-3.6.4
#?退出虛擬環(huán)境
pyenv?deactivate
</span?class="mord?mathit"?style="margin-right:0.01968em;"></span?class="mord?mathit"></span?class="mord?mathit"?style="margin-right:0.03588em;"></span?class="mord?mathit"></span?class="mord?mathit"?style="margin-right:0.05764em;"></span?class="mord?mathit"?style="margin-right:0.05764em;"></span?class="mord?mathit"></span?class="mord?mathit"></span?class="mord?mathit"></span?class="mord?mathit"></span?class="mord?mathit"?style="margin-right:0.03588em;"></span?class="mord?mathit"></span?class="mord?mathit"></span?class="mord?mathit"?style="margin-right:0.03588em;"></span?class="mord?mathit"></span?class="strut"?style="height:1em;vertical-align:-0.25em;"></span?class="katex-html"?aria-hidden="true">
創(chuàng)建 pip 配置文件
#?創(chuàng)建?pip?配置目錄mkdir?~/.pip
#?編輯配置
vim?~/.pip/.pip.conf
#?添加以下內(nèi)容
[list]
format=columns
[global]
download_cache?=?~/.cache/pip
index-url?=?http://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host=mirrors.aliyun.com
五、數(shù)據(jù)庫安裝
數(shù)據(jù)庫安裝
通過 brew service 管理此類后臺(tái)任務(wù)
brew?tap?homebrew/servicesbrew?services?start?mysql
brew?services?restart?mysql
brew?services?list
brew?services?cleanup
#?通過界面管理后臺(tái)服務(wù)
brew?cask?install?launchrocket
六、參考
主要參考
awesome-mac
open-source-mac-os-apps
Best-App
mac-setup
mac-dev-setup
dev-setup
總結(jié)
以上是生活随笔為你收集整理的还在用 Win?教你从零把 Mac 打造成开发利器的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 新一代海量数据搜索引擎 TurboSea
- 下一篇: 万字长文带你深入浅出 Golang Ru