brew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
一般运行都会出现443错误,原因是地址被墙。有两种办法解决,一种是去ipadress去输入https://raw.githubusercontent.com
这个链接,复制ip去改hosts,这种还是很慢。还有一种是直接使用国内镜像。方法如下:
安装之443解决
gitee源:
$ /bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
无法安装软件之替换镜像
# 替换成阿里巴巴的 brew.git 仓库地址:
cd "$(brew --repo)"
git remote set-url origin https://mirrors.aliyun.com/homebrew/brew.git
# 还原为官方提供的 brew.git 仓库地址
cd "$(brew --repo)"
git remote set-url origin https://github.com/Homebrew/brew.git
# 替换成阿里巴巴的 homebrew-core.git 仓库地址:
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-core.git
# 还原为官方提供的 homebrew-core.git 仓库地址
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://github.com/Homebrew/homebrew-core.git
网上还有替换为清华大学等源的方式,有空整理
brew安装nvm
$ brew install nvm
zsh修改
$ cd ~
$ vim ~/.zshrc
# 添加如下命令
export NVM_DIR=~/.nvm
source $(brew --prefix nvm)/nvm.sh
$ source ~/.zshrc
bash修改
$ cd ~
$ vim .bash_profile
# 添加如下命令
export NVM_DIR=~/.nvm
source $(brew --prefix nvm)/nvm.sh
# 或者
echo "source $(brew --prefix nvm)/nvm.sh" >> .bash_profile
$ source .bash_profile
nvm常用命令
$ nvm -h //查看nvm的指令
$ nvm list //查看本地已经安装的node版本列表
$ nvm list available //查看可以安装的node版本
$ nvm install latest //安装最新版本的node
$ nvm install [version][arch] //安装指定版本的node 例如:nvm install 10.16.3 安装node v10.16.3 arch表示电脑的位数 如果电脑需要安装32位的, 则运行:nvm install 10.16.3 32
$ nvm use [version] //使用node 例如:nvm use 10.16.3
$ nvm uninstall [version] //卸载node
nvm换国内源
$ cd ~
$ vim ~/.zshrc
# 添加如下配置文件
export NVM_NODEJS_ORG_MIRROR=http://npm.taobao.org/mirrors/node
export NVM_IOJS_ORG_MIRROR=http://npm.taobao.org/mirrors/iojs
$ source .bash_profile
brew安装yarn
如果没有安装node,Homebrew会自动安装。
$ brew install yarn
常用命令:
$ brew upgrade yarn # 升级yarn
$ yarn init # 初始化项目
$ yarn add [package] # 添加依赖包
$ yarn add [package]#[version] # 添加指定版本依赖包
$ yarn add [package]@[tag] # ...
$ yarn add [package] --dev # devDependencies
$ yarn add [package] --peer # peerDependencies
$ yarn add [package] --optional # optionalDependencies
# 升级依赖包
$ yarn upgrade [package]
$ yarn upgrade [package]@[version]
$ yarn upgrade [package]@[tag]
# 移除依赖包
$ yarn remove [package]
oh-my-zsh
下载安装包:
$ wget https://gitee.com/mirrors/oh-my-zsh/raw/master/tools/install.sh
搜索:
# Default settings
修改:
REPO=${REPO:-ohmyzsh/ohmyzsh}
REMOTE=${REMOTE:-https://github.com/${REPO}.git}
# 改为
REPO=${REPO:-mirrors/oh-my-zsh}
REMOTE=${REMOTE:-https://gitee.com/${REPO}.git}
保存退出。
运行sh文件:
$ ./install.sh run
如果出现zsh: permission denied: ./install.sh
,先要给sh文件权限,方法如下:
# 方法一
$ chmod a+x xxx.sh
# 方法二
$ chmod 777 xxx.sh
# 方法三
$ sudo chmod +x xxx.sh
重新执行安装命令:
修改仓库地址:
$ cd ~/.oh-my-zsh
$ git remote set-url origin https://gitee.com/mirrors/oh-my-zsh.git
$ git pull
这块没用到
报错:
[oh-my-zsh] Insecure completion-dependent directories detected:
解决方法:
vim ~/.zshrc
# 加入如下代码
ZSH_DISABLE_COMPFIX="true"
source ~/.zshrc
插件
-
autojump
$ brew install autojump
-
zsh-autosuggestions自动补全
$ cd ~/.oh-my-zsh/plugins $ git clone git://github.com/zsh-users/zsh-autosuggestions $ vim ~/.zshrc # plugins=(git zsh-autosuggestions) $ source ~/.zshrc
-
zsh-syntax-highlighting 高亮
$ git clone https://github.com/zsh-users/zsh-syntax-highlighting.git $ vim ~/.zshrc # plugins=(git zsh-autosuggestions zsh-syntax-highlightings) $ source ~/.zshrc
主题
powerlevel10k
字体
$ brew tap caskroom/fonts # 首次安装字体执行
$ brew cask install font-hack-nerd-font
iterm2
安装
官网下载或者:
$ brew tap caskroom/cask # 首次安装软件执行
$ brew cask install iterm2