[TOC] #### 前言 --- omz 官网:<https://ohmyz.sh> 内置插件:<https://github.com/ohmyzsh/ohmyzsh/wiki/Plugins> omz 的插件配置是 `~/.zshrc` 配置文件中的 `plugins` 配置项,多个插件使用空格隔开 ``` plugins=(git history) ``` 在 `~/.oh-my-zsh/plugins` 目录中默认已经存在了大量插件,只需要添加到上面的配置项中即可  #### [git](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/git) --- 该插件提供了很多 git 命令的别名,使用方式很简单 ``` plugins=(... git) ``` 它提供的别名太多了,很多我都用不到,而且它提供的别名我不是很满意,我会选择自己定义别名 ``` alias gi="git init" alias gs="git status" alias ga="git add -A" alias gc="git commit -m" ``` #### [wd](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/wd) --- wd 可以给目录设置索引名称,然后就可以通过索引名称快速进入到这个目录 zsh 终端配置:修改 `~/.zshrc` 文件,引用插件。[点击查看更多用法](https://www.itqaq.com/index/597.html) ``` plugins=(... wd) ``` 使用示例 ``` wd # 直接回车可以查看所有命令和参数选项 wd list # 可以所有索引名称 wd add <point> # 给当前目录设置索引名称 wd <point> # 跳转到索引名称对应的目录 ``` #### [sudo](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/sudo) --- 它的主要作用是:当我们输入某个命令发现没有系统权限,可以快速的将 sudo 作为前缀添加到命令的最前面 ``` plugins=(... sudo) ``` 双击【ESC】键就会自动添加 `sudo` 前缀  #### [aliases](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/aliases) --- 该插件用于更友好的查看命令别名,对应我这个命令别名重度使用者,挺好使的 ``` plugins=(... aliases) ``` 用法: ```bash # 按组显示所有别名 als # 查看命令参数 als -h # 查看所有组名 als --groups # 查看指定组的别名 als -g <group> # 根据关键词搜索别名 als <keyword> ``` #### [copyfile](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/copyfile) --- copyfile 用于快速拷贝文件内容,它会将文件内容拷贝到剪切板中,无需鼠标选中复制 ``` plugins=(... copyfile) ``` 使用方法 ``` # 命令格式 copyfile <文件路径> # 使用示例 copyfile ~/.ssh/id_rsa.pub ``` #### [autojump](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/autojump) --- autojump 插件用于快速跳转目录。先安装 autojump,[点击查看如何安装](https://github.com/wting/autojump#installation) ``` brew install autojump ``` 修改 `~/.zshrc` 文件,引用插件。[点击查看使用教程](https://www.itqaq.com/index/584.html) ``` plugins=(... autojump) ``` #### [web-search](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/web-search) --- 它的作用是可以让终端直接打开默认浏览器并搜索你输入的关键词 这个插件添加了别名,可用于搜索 Google、百度、必应、YouTube 等主流搜索服务 **Zsh 终端配置** ``` plugins=(... web-search) ``` 执行以下命令,会使用默认浏览器打开百度,然后搜索 `git 教程`。[点击查看更多用法](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/web-search#usage) ``` baidu git 教程 ``` 该插件还支持自定义搜索命令。如下所示:bli 命令打开哔哩哔哩官网,blis 命令打开官网并进行搜索 **Zsh 终端配置** ``` # 引用该插件 plugins=(... web-search) # 自定义搜索命令 ZSH_WEB_SEARCH_ENGINES=( bd "https://www.baidu.com/s?wd=" bli "https://www.bilibili.com" blis "https://search.bilibili.com/all?keyword=" ) ```