Mac开发环境搭建

翻墙

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

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

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

Xcode Command Line Tools

打开终端,执行

xcode-select --install

Homebrew

安装Homebrew

打开终端,执行

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

更新:

brew update
brew upgrade

brew install

brew install git
brew install zsh
brew install python
brew install autojump
brew install mysql
brew install redis
brew install rabbitmq
brew install siege
brew install nmap
brew install pipenv
brew install flake8
brew install you-get

brew cask install

  • cheatsheet (快捷键查看工具)
  • iterm2(替代终端)
  • sequel-pro(数据库管理软件)
  • github(一个git图形客户端,功能比较简单,不能stash)
  • typora(所见即所得的markdown编辑器)
  • google-chrome(浏览器)
  • fliqlo(翻页钟屏保)
  • etcher(刻录SD卡镜像)
  • android-platform-tools(安卓开发工具,包括adb、fastboot等命令)
  • sublime-text(文本编辑器)
  • iina(视频播放器)
  • omnigraffle(画流程图)
  • folx(P2P下载器)
  • charles(抓包软件)
  • dingtalk(钉钉)
  • postman(web测试工具)
  • chromedriver(配合selenium使用的chrome浏览器驱动)
  • docker(Docker CE 客户端)
  • ngrok(内网穿透工具)
  • gqrx(SDR 图形化工具)
brew cask install cheatsheet
brew cask install iterm2
brew cask install sequel-pro
brew cask install github
brew cask install typora
brew cask install google-chrome
brew cask install fliqlo
brew cask install etcher
brew cask install android-platform-tools
brew cask install android-studio
brew cask install sublime-text
brew cask install iina
brew cask install folx
brew cask install charles
brew cask install dingtalk
brew cask install wechatwebdevtools
brew cask install omnigraffle
brew cask install kindle
brew cask install postman
brew cask install chromedriver
brew cask install docker
brew cask install ngrok
brew cask install gqrx

font

brew tap caskroom/fonts
brew cask install font-mononoki
brew cask install font-source-code-pro
brew cask install font-fira-code

oh-my-zsh

安装 oh-my-zsh

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

配置 oh-my-zsh

编辑~/.zshrc文件:

# 以下是修改已经存在的配置
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

brew install mas

常用操作

常用操作与brew基本一致。

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)

配置

.zshrc

# 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 pi@192.168.2.211 -p 3154"

vim

下载 solarized 主题配色

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

.gitconfig

[user]
    name = foo
    email = name@email.com
[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

配置

{
    "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

cd ~/Library/Application Support/Sublime Text 3/Packages/User
vi coding.sublime-snippet
<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>
vi shebang.sublime-snippet
<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>

FAQ

卸载oh-my-zsh

uninstall_oh_my_zsh

Ubuntu上安装oh-my-zsh依赖

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命令;
目录