四次元科技
科技、动漫、生活、学习以及一切

新手前端工程师拿到mac后的软件和配置2.0

2025年05月04日 ·
分享 , 开发

前言

上次写新手配置已经是两年前了,现在有很多东西有了新的解决方案,所以优化一版。

核心工具

开启全部来源

如果你需要装一些奇怪的软件,可能需要开启全部来源,这样没有签名的软件不会提示损坏。

sudo spctl --master-disable

Chrome 浏览器

首先肯定是装个 Chrome 浏览器,Safari 还是乖乖的当 Chrome 下载器吧。

下载地址: https://www.google.cn/chrome

妙妙小工具

我目前比较推荐这个,下载地址 Base64 转换了一下,防止被 Ban。

aHR0cHM6Ly9naXRodWIuY29tL2NoZW4wODIwOS9GbENsYXNoL3JlbGVhc2VzL2Rvd25sb2FkL3YwLjguODQvRmxDbGFzaC0wLjguODQtbWFjb3MtYXJtNjQuZG1n

这个也可以,比较经典。

aHR0cHM6Ly9naXRodWIuY29tL2NsYXNoLXZlcmdlLXJldi9jbGFzaC12ZXJnZS1yZXYvcmVsZWFzZXMvZG93bmxvYWQvdjIuMi4zL0NsYXNoLlZlcmdlXzIuMi4zX2FhcmNoNjQuZG1n

git

因为 git 是开发所必须,很多工具也都需要用 git 来安装,所以我们要先安装 git,还是老办法,执行系统命令。

xcode-select --install

oh-my-zsh

macOS 的默认 shell 解释器用的是 zsh,而 zsh 有一个很好的插件叫做 oh-my-zsh,可以给终端增加很多功能。

由于国内特殊环境,我们使用清华大学镜像源 Tuna 来进行安装。

依次执行下面的命令即可。

cd ~/
git clone https://mirrors.tuna.tsinghua.edu.cn/git/ohmyzsh.git
cd ohmyzsh/tools
REMOTE=https://mirrors.tuna.tsinghua.edu.cn/git/ohmyzsh.git sh install.sh
rm -rf ~/ohmyzsh

安装之后,在用户根目录下会生成一个 .zshrc 的配置文件,如果后面有需要修改配置的就是修改这个文件。

使用如下命令可以打开配置文件。

open ~/.zshrc

下面的配置可以直接复制粘贴进去,也可以根据自己需求进行修改,主要集中在一些插件的设置,和环境变量的设置。

# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:$HOME/.local/bin:/usr/local/bin:$PATH

# Path to your Oh My Zsh installation.
export ZSH="$HOME/.oh-my-zsh"

# Set name of the theme to load --- if set to "random", it will
# load a random theme each time Oh My Zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
ZSH_THEME="gianu"

# Set list of themes to pick from when loading at random
# Setting this variable when ZSH_THEME=random will cause zsh to load
# a theme from this variable instead of looking in $ZSH/themes/
# If set to an empty array, this variable will have no effect.
# ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" )

# Uncomment the following line to use case-sensitive completion.
# CASE_SENSITIVE="true"

# Uncomment the following line to use hyphen-insensitive completion.
# Case-sensitive completion must be off. _ and - will be interchangeable.
# HYPHEN_INSENSITIVE="true"

# Uncomment one of the following lines to change the auto-update behavior
# zstyle ':omz:update' mode disabled  # disable automatic updates
# zstyle ':omz:update' mode auto      # update automatically without asking
# zstyle ':omz:update' mode reminder  # just remind me to update when it's time

zstyle ':omz:update' mode auto

# Uncomment the following line to change how often to auto-update (in days).
# zstyle ':omz:update' frequency 13

zstyle ':omz:update' frequency 7

# Uncomment the following line if pasting URLs and other text is messed up.
# DISABLE_MAGIC_FUNCTIONS="true"

# Uncomment the following line to disable colors in ls.
# DISABLE_LS_COLORS="true"

# Uncomment the following line to disable auto-setting terminal title.
# DISABLE_AUTO_TITLE="true"

# Uncomment the following line to enable command auto-correction.
# ENABLE_CORRECTION="true"

# Uncomment the following line to display red dots whilst waiting for completion.
# You can also set it to another string to have that shown instead of the default red dots.
# e.g. COMPLETION_WAITING_DOTS="%F{yellow}waiting...%f"
# Caution: this setting can cause issues with multiline prompts in zsh < 5.7.1 (see #5765)
# COMPLETION_WAITING_DOTS="true"

# Uncomment the following line if you want to disable marking untracked files
# under VCS as dirty. This makes repository status check for large repositories
# much, much faster.
# DISABLE_UNTRACKED_FILES_DIRTY="true"

# Uncomment the following line if you want to change the command execution time
# stamp shown in the history command output.
# You can set one of the optional three formats:
# "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
# or set a custom format using the strftime function format specifications,
# see 'man strftime' for details.
# HIST_STAMPS="mm/dd/yyyy"

# Would you like to use another custom folder than $ZSH/custom?
# ZSH_CUSTOM=/path/to/new-custom-folder

# Which plugins would you like to load?
# Standard plugins can be found in $ZSH/plugins/
# Custom plugins may be added to $ZSH_CUSTOM/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(git macOS zsh-nvm zsh-proxy)

source $ZSH/oh-my-zsh.sh

# User configuration

# export MANPATH="/usr/local/man:$MANPATH"

# You may need to manually set your language environment
# export LANG=en_US.UTF-8

# Preferred editor for local and remote sessions
# if [[ -n $SSH_CONNECTION ]]; then
#   export EDITOR='vim'
# else
#   export EDITOR='nvim'
# fi

# Compilation flags
# export ARCHFLAGS="-arch $(uname -m)"

# Set personal aliases, overriding those provided by Oh My Zsh libs,
# plugins, and themes. Aliases can be placed here, though Oh My Zsh
# users are encouraged to define aliases within a top-level file in
# the $ZSH_CUSTOM folder, with .zsh extension. Examples:
# - $ZSH_CUSTOM/aliases.zsh
# - $ZSH_CUSTOM/macos.zsh
# For a full list of active aliases, run `alias`.
#
# Example aliases
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"

# Homebrew Start
export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git"
export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git"
export HOMEBREW_API_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles/api"
export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles/bottles"
# Homebrew End

# NVM Start
export NVM_NODEJS_ORG_MIRROR=https://cdn.npmmirror.com/binaries/node
export NVM_SYMLINK_CURRENT=true
export NVM_COMPLETION=true
export NVM_LAZY_LOAD=true
export COREPACK_ENABLE_AUTO_PIN=0
# NVM End

# Android Start
export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools
# Android End

homebrew

Homebrew 是一款终端包管理器,可以用来安装环境需要的一些软件。

官方的安装方式国内会比较慢,这里推荐国内镜像的方式安装,配置上面已经加好了。

详细介绍可以阅读镜像助手 - Homebrew 中文网

/bin/bash -c "$(curl -fsSL https://gitee.com/ineo6/homebrew-install/raw/master/install.sh)"

zsh-proxy

zsh-proxy 是一个可以快速设置终端代理的插件,有时候终端网络连接不稳定,就可以用这个插件快速解决问题。

具体的使用说明可以参考 https://github.com/SukkaW/zsh-proxy

git clone https://github.com/sukkaw/zsh-proxy.git ~/.oh-my-zsh/custom/plugins/zsh-proxy
source $HOME/.zshrc
init_proxy

开发工具

nvm

我们使用 nvm 来安装 node,nvm 可以管理 node 版本,想要更新或者切换 node 版本的时候就会很方便。

由于我们使用了 oh-my-zsh,我们可以用 zsh-nvm 插件来安装。

相关的配置上面已经添加过了,这里只要下载插件就好了。

git clone https://github.com/lukechilds/zsh-nvm ~/.oh-my-zsh/custom/plugins/zsh-nvm
source $HOME/.zshrc

node

使用 nvm 安装 lts 版的 node,并且开启 yarn 和 pnpm 支持。

# 安装 lts 版 node
nvm install --lts
corepack enable yarn
# 安装 yarn 1.x
corepack install yarn@1.22.22
# 安装 yarn 3.x
corepack install yarn@3.8.7
# 开启 pnpm
corepack enable pnpm

还要添加下面的设置到用户目录的 .npmrc 里面。

node-mirror:release=https://npmmirror.com/mirrors/node/
node-mirror:rc=https://npmmirror.com/mirrors/node-rc/
node-mirror:nightly=https://npmmirror.com/mirrors/node-nightly/
# 如果需要开发RN,记得设置为hoisted模式,否则RN项目不可用。
# 也可设置到项目的.npmrc中。
node-linker=hoisted

ReactNative 开发还要在用户目录的 .zprofile 里加入下面的内容,不然可能会导致编译 ReactNative 找不到 node。

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"

VSCode

现在大家一般都是常用 VSCode。直接点下面链接下载就行。

下载地址: https://code.visualstudio.com/sha/download?build=stable&os=darwin-universal

但是十有八九你的下载速度会特别特别的慢。这时候有两种方案。

一种是复制一下下载的链接,改成国内镜像源。

也就是把 xxxxxx.vo.msecnd.net 改成 vscode.cdn.azure.cn

# 原始地址
https://az764295.vo.msecnd.net/stable/f1b07bd25dfad64b0167beb15359ae573aecd2cc/VSCode-darwin-universal.zip
# 修改后地址
https://vscode.cdn.azure.cn/stable/f1b07bd25dfad64b0167beb15359ae573aecd2cc/VSCode-darwin-universal.zip

也可以试试 VSCode 的开源版本 VSCodium,没有微软服务,更轻量。

下载地址: https://github.com/VSCodium/vscodium/releases/download/1.92.1.24225/VSCodium.arm64.1.92.1.24225.dmg

安装 ReactNative 环境

如果你是 Web 前端的话,看到这基本就差不多了,但是如果你是 ReactNative 开发的话,那后面还要再搞一坨东西才好用。

XCode

xcode 可以在下面的网址直接找到下载,这样可以下载一些指定的版本,比如 RN 目前最好下载 16.2 以下版本,16.3+ 的版本会导致无法编译。

下载地址: https://xcodereleases.com/?scope=release

Android Studio

Android Studio 直接到中文官网下载。

下载地址: https://developer.android.google.cn/studio?hl=zh-cn

如果想要在 Android Studio 里运行 Android 端项目,请务必在设置中把 gradle 的 jdk 版本设置为 17

Watchman

homebrew 一行命令安装。

brew install watchman

Cocoapods

这玩意和 watchman 一样,用 homebrew 一行命令安装。

brew install cocoapods

一些好用的软件

Easydict(划词翻译)

Easydict 是一款开源的翻译软件,支持划词翻译,截图翻译等等,很好用。

下载地址: https://github.com/tisfeng/Easydict/releases/download/2.14.1/Easydict.dmg

也可以使用 homebrew 安装

brew install --cask easydict

LinearMouse(鼠标滚轮反转)

相信很多人用 macOS 外接鼠标的时候,对滚轮和 Windows 相反这件事很难受,而直接在设置里面修改,又会导致触摸板的滚动也相反,于是就可以用这个软件来更改。

这个软件同时也会修改鼠标的移动速度,让外接鼠标不会变得很“飘”。

下载地址: https://dl.linearmouse.org/latest/LinearMouse.dmg

也可以使用 homebrew 安装

brew install --cask linearmouse

ice(任务栏管理器)

新版的 mac 笔记本上面都有一条刘海,外接了显示器还好,如果不接显示器,经常会导致图标显示不全。

这时候 ice 这款软件就能帮你解决这个问题。

下载地址: https://github.com/jordanbaird/Ice/releases/download/0.11.12/Ice.zip

LocalSend(局域网文件传输)

类似 AirDrop 的功能,只要是内网就能传。

下载地址: https://localsend.org/download

# macOS # 前端 # 开发
评论