跳转至

安装实用的插件

https://hufangyun.com/2017/zsh-plugin/

https://www.haoyep.com/posts/zsh-config-oh-my-zsh/

1. zsh-syntax-highlighting

平常用的lscd 等命令输入正确会绿色高亮显示,输入错误会显示其他的颜色。

在输入命令的过程中,若指令不合法,则指令显示为红色,若指令合法就会显示为绿色。

Bash
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting

# 中国用户可以使用下面任意一个加速下载
# 加速1
git clone https://github.moeyy.xyz/https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
# 加速2
git clone https://gh.xmly.dev/https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
# 加速3
git clone https://gh.api.99988866.xyz/https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting

2. zsh -autosuggestions

一个命令提示插件,当你输入命令时,会自动推测你可能需要输入的命令,按下右键可以快速采用建议。

Bash
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

# 中国用户可以使用下面任意一个加速下载
# 加速1
git clone https://github.moeyy.xyz/https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
# 加速2
git clone https://gh.xmly.dev/https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
# 加速3
git clone https://gh.api.99988866.xyz/https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

3. z

oh-my-zsh 内置了 z 插件。z 是一个文件夹快捷跳转插件,对于曾经跳转过的目录,只需要输入最终目标文件夹名称,就可以快速跳转,避免再输入长串路径,提高切换文件夹的效率。

Bash
cd workspace/test
cd
z test   # (tab)

4. extract

oh-my-zsh 内置了 extract 插件。extract 用于解压任何压缩文件,不必根据压缩文件的后缀名来记忆压缩软件。使用 x 命令即可解压文件。

Bash
x test.tar.bz2

对插件进行启用

/Users/ken/.oh-my-zsh/plugins目录下有所有支持的插件,不要里面的需要额外再安装。

Bash
# 我所作用的设置
# .zshrc add
plugins=(git zsh-autosuggestions zsh-syntax-highlighting z extract)

source $ZSH/oh-my-zsh.sh

自定义插件在这里,可以直接从其它机器复制过来放在这里。

Bash
/home/ken/.oh-my-zsh/custom/plugins