文章目录
item2 安装
- 下载 :https://iterm2.com/features.html
Oh My Zsh 安装
1. List item下载
- curl
$ sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
- wget
$ sh -c "$(wget https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"
2. 目录介绍
其实以上的安装,就是下载了oh my zsh的git仓库而已。进入~/.oh-my-zsh目录后,看看该目录的结构
$ ls .oh-my-zsh
CODE_OF_CONDUCT.md README.md lib plugins tools
CONTRIBUTING.md cache log templates
LICENSE.txt custom oh-my-zsh.sh themes
- lib 提供了核心功能的脚本库
- tools 提供安装、升级等功能的快捷工具
- plugins 自带插件的存在放位置
- templates 自带模板的存在放位置
- themes 自带主题文件的存在放位置
- custom 个性化配置目录,自安装的插件和主题可放这里
本次配置,我们只需要关心plugins
和themes
两个目录,可以进入这两个目录中看看,oh my zsh默认提供了哪些插件和主题。
看下自带的有哪些插件
$ ls ~/.oh-my-zsh/plugins
adb debian git-flow last-working-dir profiles systemd
alias-finder dircycle git-flow-avh lein pyenv taskwarrior
ansible direnv git-hubflow
省略...
自带的主题
ls ~/.oh-my-zsh/themes
3den.zsh-theme gallifrey.zsh-theme nebirhos.zsh-theme
Soliah.zsh-theme gallois.zsh-theme nicoulaj.zsh-theme
adben.zsh-theme garyblessington.zsh-theme norm.zsh-theme
af-magic.zsh-theme gentoo.zsh-theme obraun.zsh-theme
afowler.zsh-theme geoffgarside.zsh-theme peepcode.zsh-theme
agnoster.zsh-theme gianu.zsh-theme philips.zsh-theme
alanpeabody.zsh-theme gnzh.zsh-theme pmcgee.zsh-theme
省略...
3、主题配置
修改.zshrc文件,从~/.oh-my-zsh/themes
目录中找到想要使用的主题,把主题名称配置到.zshrc文件中key为ZSH_THEME的值即可。
主题只能配置一个,格式如下:
ZSH_THEME="themeName"
我使用的是ys.zsh-theme这个主题,配置的时候需要省略后面的.zsh-theme,即ys,如下:
3.1 编辑.zshrc文件
vim ~/.zshrc
3.2 修改主题
ZSH_THEME="ys"
3.3 生效
source ~/.zshrc
你也可以使用random这个主题
ZSH_THEME="random"
意思是每次打开终端都随机使用一个主题,直到那天你看着哪个主题好看了,使用 echo 命令输出当前主题的名称,再改为这个喜欢的主题即可。
$ echo $ZSH_THEME
4、插件配置
跟上面的配置主题类似,修改.zshrc
文件,从~/.oh-my-zsh/plugins
目录中找到想要使用的插件,把插件名称配置到.zshrc
文件中key为plugins
的值即可。
插件可以配置多个,格式如下:
plugins=(plugin1 plugin2 plugin3)
4.1 编辑.zshrc文件
vim ~/.zshrc
4.2 填入需要的插件
plugins=(git zsh-autosuggestions zsh-syntax-highlighting web-search)
4.3 生效
source ~/.zshrc
5、扩展插件
使用扩展的插件,需要把对应的插件下载到 ~/.oh-my-zsh/plugins文件夹中,然后修改.zshrc文件,把该插件名填入到plugins的位置;
5.1自动命令提示 zsh-autosuggestions
- 功能:在终端输入命令的时候,会自动出现你之前输入过的命令,此时按下 →键就可以补全命令了。
这个不是oh my zsh自带的插件,需要下载到插件目录(~/.oh-my-zsh/plugins)中 - 获取插件:
git clone git://github.com/zsh-users/zsh-autosuggestions ~/.oh-my-zsh/plugins/zsh-autosuggestions
- 启用插件:修改~/.zshrc文件,在plugins中的值后,加入该插件名称即可。
plugins=(省略之前的插件名称 zsh-autosuggestions)
5.2语法高亮 zsh-syntax-highlighting
- 功能:输入的ls、cd等命令会变为高亮的颜色
- 获取插件:
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ~/.oh-my-zsh/plugins/zsh-syntax-highlighting
- 启用插件:修改~/.zshrc文件,在plugins中的值后,加入该插件名称即可。
plugins=(省略之前的插件名称 zsh-syntax-highlighting)
5.3 代码补全 zsh-completions
- 功能:
- 获取插件:
git clone https://github.com/zsh-users/zsh-completions ${ZSH_CUSTOM:=~/.oh-my-zsh/custom}/plugins/zsh-completions
- 启用插件:修改~/.zshrc文件,在plugins中的值后,加入该插件名称即可。
plugins=(省略之前的插件名称 zsh-completions)