本文章参考自 Stille 的原创文章.如需转载请联系作者获得授权,并注明转载地址.
记录下操作过程:【当前文章仅仅用于记录笔记~~~】
一、配置修改终端环境
// 输入命令,检查是否有/bin/zsh(macOS自带zsh)
cat /etc/shells
// 修改默认的bash为zsh,重启Terminal
chsh -s /bin/zsh
// 检查修改结果,显示/bin/zsh即成功.
echo $SHELL
二、安装配置oh-my-zsh
// 国内地址安装
sh -c "$(curl -fsSL https://gitee.com/shmhlsy/oh-my-zsh-install.sh/raw/master/install.sh)"
// 国外地址被墙了
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
- 安装oh-my-zsh很大可能报错 443。解决方法如下:(有时候并不管用,建议国内地址安装即可)
// 查询ip(被墙的解决方法)
http://www.882667.com/ip_raw.githubusercontent.com.html
// 修改 hosts
sudo vim /etc/hosts
// 添加以下内容:
185.199.108.133 raw.githubusercontent.com
// 然后再次执行上面的安装命令即可
三、配置Terminal.(下载字体及主题,可直接忽略此步到第四步)
// 下载Menlo-for-Powerline字体包,包内字体分别双击安装到系统内.
GitHub地址: `https://github.com/abertsch/Menlo-for-Powerline`
// 主题:推荐使用Solarized
GitHub地址: `https://github.com/altercation/solarized`
找到对应的主题,比如我们用的是Terminal终端,就找到osx-terminal.app-colors-solarized下的三个文件,双击安装即可
配置Terminal
- 在刚下载的Solarized包内,找到Solarized-for-Terminal中的Solarized Dark Higher Contrast.terminal,双击运行即打开Terminal.
- 打开偏好设置-描述文件
- 左侧Solarized Dark Higher Contrast点击下面的默认,设置为默认主题.
- 字体选择安装好的Menlo for Powerline即配置完毕.
四、 配置VSCode
- 打开VScode-找到设置-搜索setting.json并编辑
- 添加以下代码,保存即可.
"terminal.integrated.shell.osx": "zsh",
"terminal.integrated.fontFamily": "Menlo for Powerline" // 此处是配置字体,可忽略
五、安装zsh插件
// 安装插件
git clone https://github.com/zsh-users/zsh-autosuggestions.git $ZSH_CUSTOM/plugins/zsh-autosuggestions
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git $ZSH_CUSTOM/plugins/zsh-syntax-highlighting
// 等同于下面
cd ~/.oh-my-zsh/custom/plugins
git clone https://github.com/zsh-users/zsh-autosuggestions.git
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git
// 接下来编辑~/.zshrc文件
vi ~/.zshrc
plugins=(git zsh-autosuggestions zsh-syntax-highlighting)
// 保存退出后重启 .zshrc
source ~/.zshrc
六、更新oh my zsh
upgrade_oh_my_zsh // 废弃了
提示Note: `upgrade_oh_my_zsh` is deprecated. Use `omz update` instead.
omz update
image.png
更新成功显示如图