如何快速初始化 MacOS 开发环境

很多开发者比较喜欢用MacBook作为生产力工具,对于新电脑可以快速配置下开发环境。

MacOS 开发者初始化工具

打开以及关闭隐藏目录

1
shift + command + .

安装开发工具

1
xcode-select --install

brew 工具使用

  1. 安装brew工具
1
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" 
  1. brew 基本命令
1
2
3
4
5
6
7
8
9
brew -h #查找命令
brew search #搜索软件
brew install #安装软件
brew uninstall #卸载软件
brew update #更新所有软件
brew upgrade #更新具体软件
brew list #显示安装软件
brew info / home# 查看软件信息:(home是打开软件的官网)
brew outdated #查看哪些软件需要更新

oh my zsh 安装以及配置插件

  1. 安装oh my zsh
1
$ sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
  1. 安装autojump插件
1
brew install autojump
  1. 安装zsh-autosuggestion插件
1
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions 
  1. 安装zsh-syntax-highlighting插件
1
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
  1. 配置以及激活插件
1
2
vim ~/.zshrc # 添加选项
plugins=(git autojump zsh-autosuggestions zsh-syntax-highlighting) # 重启控制台

oh my zsh 配置 powerlevel10k 主题

  1. 安装 powerlevel10k
1
2
3
git clone --depth=1 https://gitee.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k

# 配置方式 Set ZSH_THEME="powerlevel10k/powerlevel10k" in ~/.zshrc.
  1. 配置powerlevel10k
1
p10k configure # 通过交互配置主题

MacOS Hight Sierra清除DNS缓存

1
sudo dscacheutil -flushcache;sudo killall -HUP mDNSResponder;

安装常用软件

1
2
3
4
5
6
7
8
9
brew cask install v2rayu
brew cask install shadowsocksx-ng
brew install redis
brew install helm
brew install kubernetes-cli
brew install mysql
brew cask install visual-studio-code
brew cask install typora
brew cask install iterm2