官网下载地址
Mac系统默认使用dash作为终端,可以使用命令修改默认使用zsh:chsh -s /bin/zsh
如果想修改回默认dash,同样使用chsh命令即可:chsh -s /bin/bash
官方提供两种安装方式,可以任选一种
# curl 安装方式
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
# wget 安装方式
sh -c "$(wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"
当使用以上两种方法都报错时,可尝试以下方法手动安装:
# 下载 oh-my-zsh 源码
git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh
# 并且把 .zshrc 配置文件拷贝到根目录下
cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
# 让 .zshrc 配置文件生效
source ~/.zshrc
使用命令 pip install powerline-status --user
安装
如安装过程中提示没有pip则使用sudo easy_install pip
如果命令仍然执行错误,可能是由于本机默认python2,此时我们安装并默认使用python3,操作如下:
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
brew update
brew install python
/usr/local/Cellar/
目录下是否有python3开头的文件夹,如有既是安装成功# 下面Cellar后面的路径根据自身实际python版本修改
export PATH=${PATH}:/usr/local/Cellar/[email protected]/3.9.6/bin
alias python=/usr/local/Cellar/[email protected]/3.9.6/bin/python3
alias pip=/usr/local/Cellar/[email protected]/3.9.6/bin/pip3
安装字体库需要首先将项目git clone至本地,然后执行源码中的install.sh。
在你习惯的位置新建一个文件夹,如:/Users/dj/opensource
mkdir /Users/dj/opensource
cd /Users/dj/opensource
git clone https://github.com/powerline/fonts.git --depth=1
cd fonts
./install.sh
安装好字体库之后,设置iTerm2的字体,具体的操作是iTerm2 -> Preferences -> Profiles -> Text,在Font区域选中Change Font,然后找到Meslo LG字体。
cd /Users/dj/opensource
git clone https://github.com/altercation/solarized
cd solarized/iterm2-colors-solarized/
open .
在打开的finder窗口中,双击Solarized Dark.itermcolors和Solarized Light.itermcolors即可安装明暗两种配色。
再次进入iTerm2 -> Preferences -> Profiles -> Colors -> Color Presets中根据个人喜好选择这两种配色中的一种即可。
下载agnoster主题,执行脚本安装:
cd /Users/dj/opensource
git clone https://github.com/fcamblor/oh-my-zsh-agnoster-fcamblor.git
cd oh-my-zsh-agnoster-fcamblor/
./install
拷贝完成后,执行vim ~/.zshrc
命令打开zshrc配置文件,将ZSH_THEME后面的字段改为agnoster。
cd ~/.oh-my-zsh/custom/plugins/
# 高亮插件
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git
# 命令补全插件
git clone https://github.com/zsh-users/zsh-autosuggestions
vi ~/.zshrc
这时我们打开zshrc文件进行编辑。找到plugins,此时plugins中应该已经有了git,我们需要把高亮插件和命令补全插件也加上,高亮插件zsh-syntax-highlighting必须放在最后一个,并且在文件的最后添加 source ~/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
,执行source ~/.zshrc
使文件生效。
更换背景图片方式:iTerm2 -> Preferences -> Profiles -> Window -> BackGround Image勾选图片即可。