如何在Mac上快速安装oh-my-zsh下的插件zsh-autosuggestion
1、官方资源和github地址信息
2、安装方法
2.1 mac自带了zsh,需要更新
brew install zsh zsh-completions
2.2 set up zsh as default(把zsh设置成默认shell)
#设置
chsh -s $(which zsh)
#查检-需要关闭终端重新打开后生效
echo $SHELL
2.3 安装 oh my zsh
这里需要注意zsh是安装oh my zsh 的Prerequisites(前置条件)
2.3.1 下载oh my zsh到~/.oh-my-zsh
1、通过curl方式安装:
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
2、通过wget方式安装
sh -c "$(wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
以上两个方式都是很慢的安装方式
这是使用git方式clone下载安装的,这里github下载也很慢,有个好办法,通过gitee安装
先将github项目导入自己的gitee仓库-ohmyzsh.git,然后再clone国内仓库速度飞快,或者你自己重新同步。
git clone https://gitee.com/null_454_5218/ohmyzsh.git ~/.oh-my-zsh
2.3.2 zshrc的配置信息【来自模板】
vi ~/.zshrc
#内容从这个模板来
/Users/honglei/.oh-my-zsh/templates/zshrc.zsh-template
#记得最后
source ~/.zshrc
2.4 安装 oh my zsh的plugins
2.4.1下载插件到/.oh-my-zsh/custom目录中
git clone https://gitee.com/null_454_5218/zsh-autosuggestions.git $ZSH_CUSTOM/plugins/zsh-autosuggestions
2.4.2 配置文件中,添加支持的插件
For example, this might begin to look like this:
plugins=(
git
zsh-autosuggestions
bundler
dotenv
osx
rake
rbenv
ruby
)
2.4.3 使用帮助
As you type commands, you will see a completion offered after the cursor in a muted gray color. This color can be changed by setting the ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE variable. See configuration.
键入命令时,您会在光标后看到灰色的静音形式的补全。 可以通过设置ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE变量来更改此颜色。 请参阅配置。
If you press the → key (forward-char widget) or End (end-of-line widget) with the cursor at the end of the buffer, it will accept the suggestion, replacing the contents of the command line buffer with the suggestion.
如果在光标位于缓冲区末尾的位置按→键(前向字符小部件)或End(行尾小部件),它将接受建议,并用建议替换命令行缓冲区的内容。
If you invoke the forward-word widget, it will partially accept the suggestion up to the point that the cursor moves to.
如果您调用前向小部件,它将一直接受建议直到光标移动到的位置。