安装美丽的iterm2,从零开始,避免踩坑

1,143 阅读2分钟
1. 安装 iTerm2官网下载
2. 打开iTerm2,下面的操作在iTerm2上执行
3. 安装 oh-my-zsh
curl -L https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh | sh

如果出现

curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused

可以执行下面这句 443 端口连接被拒一般是因为墙的原因,如果你可以科学上网(Virtual Private Network)的话,在命令行键以下命令执行:

export https_proxy=http://127.0.0.1:7890 http_proxy=http://127.0.0.1:7890 all_proxy=socks5://127.0.0.1:789

这个方法不便之处在于,运行完上述的那行命令后,终端当前 session 的所有命令都是翻墙的,解决方法也很简单:关掉当前的终端会话(或者暴力点,关掉终端重新打开)即可。

4. 安装 Powerline
pip install powerline-status

如果没有pip,出现zsh: command not found: pip。,先执行下面这个命令

sudo easy_install pip
5. 安装字体文件fonts
# clone
git clone https://github.com/powerline/fonts.git --depth=1
# install
cd fonts
./install.sh
# clean-up a bit
cd ..
rm -rf fonts
6. 设置字体

这里字体我都选择的是Meslo LG L DZ for Powerline

image.png

image.png

7. 安装配色 solarized
git clone git://github.com/altercation/solarized.git

cd solarized/iterm2-colors-solarized
open .

打开了文件夹后 双击这两个文件夹就可以把配置文件导入到iTerm2里

8. 安装主题 oh-my-zsh-agnoster-fcamblor
1. git clone git@github.com:fcamblor/oh-my-zsh-agnoster-fcamblor.git
2. vi ~/.zshrc
3. 输入i开始编辑
4. 找到ZSH_THEME然后改成ZSH_THEME="agnoster"
5. 修改完后按esc键
6. 然后输入:wq保存退出
9. 安装高亮 zsh-syntax-highlighting
1. git clone git://github.com/zsh-users/zsh-syntax-highlighting.git
2. 找到.zshrc所在目录,输入pwd -P 查看.zshrc当前所在位置【XXX】
3. vi ~/.zshrc
4. 输入i开始编辑
5. 最后一行添加source XXX/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
XXX就是刚才.zshrc所在目录
6. 找到plugins=(...) 添加zsh-syntax-highlighting 比如原来是plugins=(git)设置后plugins=(git zsh-syntax-highlighting)

zsh-syntax-highlighting一直在最后

10. 命令自动补全zsh-autosuggestions
1. cd ~/.oh-my-zsh/custom/plugins/
2. git clone https://github.com/zsh-users/zsh-autosuggestions
3. vi ~/.zshrc
找到plugins,加上这个插件即可:plugins=(git zsh-autosuggestions zsh-syntax-highlighting)

输入一个g就有后面的提示了 image.png

11. 添加背景

image.png

vscode乱码解决

编辑settings.json文件添加以下配置 "terminal.integrated.shell.osx": "/bin/zsh", "terminal.integrated.fontFamily": "Source Code Pro for Powerline"

参考链接: iTerm 2 && Oh My Zsh【DIY教程——亲身体验过程】