Zsh 常用插件
1. 插件的配置
在
~/.zshrc
中配置:plugins=(autojump sublime web-search zsh-autosuggestions extract)
有的插件还需要在
~/.oh-my-zsh/custom/plugins
目录下把相应的包 git clone 下来
2. autojump
autojump 也是一个目录直接快速跳转的效率工具,它会自动记录之前访问过的目录,并计算权重。
在
~/.zshrc
中除了配置plugins=(autojump)
之外, 还需做两件事情:- 在
~/.zshrc
中要加一行unset GEM_HOME [[ -s $(brew --prefix)/etc/profile.d/autojump.sh ]] && . $(brew --prefix)/etc/profile.d/autojump.sh
brew install autojump
用法也很简单
j directory_name
即可。- 比如我要访问
~/workspace/src
,只需要输入j src
就行了……
3. sublime
可以方便的在 Zsh 终端中调用 Sublime Text 打开文件;
比如输入
st README.md
就可以调用机器上安装的Sublime Text 打开当前目录的 README.md 文件进行编辑操作。
4. web-search
- 一个方便的终端搜索工具,支持大多常用的搜索引擎,比如:
- 输入 baidu hhkb pro2 直接在浏览器打开百度搜索关键字 ”hhkb pro2”
输入 google minila air 直接在浏览器打开Google 搜索关键字 ”minila air”
通过查看这个插件的代码,可以看到支持的搜索引擎,包括baidu, google, bing, yahoo, GitHub 等等
5. zsh-autosuggestions
命令自动提示插件,能记录平时你输入过的命令,下次再输入的时候,它会提前提示你,方便懒人。
如果是你需要的命令,直接 方向键「->」选择
需要安装两个插件:
将上面两个包的代码仓库克隆到 ~/.oh-my-zsh/custom/plugins 目录中:
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting git clone git://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions
- 在 ~/.zshrc 中 配置
plugins=( [plugins...] zsh-autosuggestions zsh-syntax-highlighting)
source ~/.zshrc
配置 ~/.zshrc 增加高亮的颜色设置:
# Enable autosuggestions automatically. ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=10"
6. extract
一个功能强大的解压插件,所有类型的文件解压通过一个命令 x 全搞定,再也不需要去记 tar 后面到底是哪几个参数了。
比如: x backup.tar.gz 或者 x temp.zip