ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

brew、zsh、iterm2、nvm、oh-my-zsh安装手记

2020-12-24 13:03:37  阅读:339  来源: 互联网

标签:git oh iterm2 yarn install brew nvm zsh


brew

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

重新执行安装命令:

image-20201223195925541

修改仓库地址:

$ 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

插件

  1. autojump

    $ brew install autojump
    
  2. zsh-autosuggestions自动补全

    $ cd ~/.oh-my-zsh/plugins
    $ git clone git://github.com/zsh-users/zsh-autosuggestions
    $ vim ~/.zshrc
    # plugins=(git zsh-autosuggestions)
    $ source ~/.zshrc
    
  3. 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

配色

solarized

标签:git,oh,iterm2,yarn,install,brew,nvm,zsh
来源: https://www.cnblogs.com/linfe/p/14183422.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有