如何升级我的 Mac 以便在 Catalina macOS 中进行开发
检查/设置我的主文件夹
安装 Xcode
安装 Xcode 命令行工具
配置 git config
设置全局 .gitignores
安装 iterm2
安装 oh my zsh
安装 NVM
安装 Ruby
Homebrew、Postgresql、MySql、ElasticSearch、Redis 和其他应用程序
Android开发+React-Native
我使用的其他应用程序
Atom 包
升华
其他东西,
我之前的文章《如何设置我的 Mac 进行开发》在旧版 macOS 上也能正常运行。
我还制作了一个视频,如果你在安装 ruby、python、nodejs 时遇到问题,可以看看这个视频
但现在它是 Catalina,bash
已经改变zsh
,我想在这里记录我的设置和其他发现。
大部分步骤都相同,除了nvmrc
部分
检查/设置我的主文件夹
我有时会看到有人在主文件夹中使用较长的用户名。我通常会选择简短易记的用户名。我的用户名是sakko
。
要检查,请输入 open Terminal 并输入pwd
$ pwd
/Users/sakko
如果你不喜欢,现在就想办法改变它,然后再继续。几个月后再改变它会非常困难。
安装 Xcode
从这里https://developer.apple.com/download/more/或 Apple App Store 下载 Xcode。
然后尝试创建一个单页应用 iOS 项目。运行该项目,看看是否构建成功。
安装 Xcode 命令行工具
打开终端并输入
$ xcode-select --install
然后点击install
继续
配置 git config
打开终端并输入这些(替换您的姓名和电子邮件)
$ git config --global user.name "John Doe"
$ git config --global user.email "john.doe@gmail.com"
设置全局 .gitignores
Mac 上有一些烦人的文件,git 可能会忽略它们。让我们添加它们。
$ nano ~/.gitignore
然后添加这些
# Node
npm-debug.log
# Mac
.DS_Store
.AppleDouble
.LSOverride
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
# Windows
Thumbs.db
# WebStorm
.idea/
完成后,通过运行来全局激活它
$ git config --global core.excludesfile ~/.gitignore
安装 iterm2
安装 oh my zsh
这里完整解释如下:https://github.com/robbyrussell/oh-my-zsh
但为了快速安装只需运行
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
然后重启终端
安装 NVM
对于nodejs开发,打开https://github.com/nvm-sh/nvm
复制安装行(例如)
$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.1/install.sh | bash
打开~/.zshrc
并查看这些行是否存在。(如果没有,请添加)
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
.nvmrc
如果您在项目中使用来激活节点版本.ruby-version
,那么您可能需要nvm-auto
从https://github.com/dijitalmunky/nvm-auto安装
逐行运行
cd ~/.oh-my-zsh/custom/plugins
git clone https://github.com/dijitalmunky/nvm-auto.git
sed -e 's/^plugins=(\(.*\))/plugins=(\1 nvm-auto)/' -i .pre-nvm-auto ~/.zshrc
echo 'nvm_auto_switch' >> ~/.zshrc
source ~/.zshrc
重启终端然后安装nodejs(仅限你使用的版本)
$ nvm install 10.16.0
$ nvm install node # this will install latest
安装 Ruby
我是一名 Rails 开发者,所以也需要 Ruby。我选择 rvm(类似 nvm)来管理版本和 gemset。
只需运行以下命令并按照提示进行操作。
$ \curl -sSL https://get.rvm.io | bash -s stable
完成后,重新启动终端一次,以加载 rvm。
安装 ruby,我目前2.5.3
使用2.6.3
$ rvm install 2.5.3
$ rvm install 2.6.3
我不喜欢安装文档(为了节省空间),所以我通常会全局忽略它。(不确定现在是否还有这个必要)
$ echo "gem: --no-document" >> ~/.gemrc
然后安装最新版本的 Rails
$ gem install rails
Homebrew、Postgresql、MySql、ElasticSearch、Redis 和其他应用程序
RVM 将为您安装 Homebrew,因此您无需重新安装它。
那么让我们安装其他应用程序
# image processing
$ brew install imagemagick gs vips
# postgresql or postgresql@11
$ brew install postgresql
$ brew services start postgresql # to start service
# mysql
$ brew install mysql
$ brew services start mysql # to start service
# redis
$ brew install redis
$ brew services start redis # to start service
# memcached
$ brew install memcached
$ brew services start memcached # to start service
安装 ElasticSearch 需要 Java8,您可以从这里下载它们。
- https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
- https://www.oracle.com/technetwork/java/javase/downloads/jre8-downloads-2133155.html
同意条款或使用 Homebrew 的 openjdk
$ brew tap AdoptOpenJDK/openjdk
$ brew cask install adoptopenjdk8
然后安装ElasticSearch
# elasticsearch
$ brew install elasticsearch
$ brew services start elasticsearch # to start service
Android开发+React-Native
最好的教程是官方的。
https://facebook.github.io/react-native/docs/getting-started
我使用的其他应用程序
- Atom.io
- VSCode
- 升华
- iTerm2
- 阿尔弗雷德
- 1Password
- 小飞贼
- iStat菜单
Atom 包
我通常从这些包开始,(你需要install shell command
先从 Atom 应用程序菜单中)
apm install atom-beautify blame console-log editorconfig emmet es6-javascript language-docker language-javascript-jsx language-plantuml language-vue linter linter-swagger linter-ui-default plantuml-preview prettier-atom rails-snippets react ruby-block set-syntax indent-guide-improved
升华
如果我想快速打开某个文件(尤其是 JSON 文件),我通常会使用 Sublime。因为它是我能找到的最快、功能齐全的编辑器。以下是我常用的软件包。
Babel
Emmet
GitGutter
JsPrettier
JSX
JsFormat
还可以使用以下方式启用 CLI
sudo ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/local/bin/subl
其他东西,
Docker - 还没有,我正在保存我珍贵的 256GB SSD T____T
python、gcloud、ansible 等等等等……太多了,无法添加。以后再安装吧。
文章来源:https://dev.to/sakko/how-i-upgrade-my-mac-for-development-in-catalina-macos-33g1