ubunut 16.04安装oh-my-zsh和zsh-autosuggestions

zsh是一个类似余linux上原生bash shell的一个shell,是原生的bash shell的拓展,我们在敲击命令的时候,历史命令都会经常的被用到,如果terminal能够提示,就大大减少了我们的敲击历史命令的时间了,这样能够提高效率,但是原生的shell并没有提供这种功能,我这里用zsh解决。

1. oh-my-zsh安装

sudo apt-get update
sudo apt-get install zsh
sh -c "$(wget https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"

然后termianl关闭,然后重新登陆就可以启用zsh啦

2.zsh-autosuggestions安装

这个也很简单

git clone https://github.com/zsh-users/zsh-autosuggestions ~/.zsh/zsh-autosuggestions
source ~/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh

然后你会惊奇的发现,你在敲击一些命令的时候,会自动提示你的历史命令,是不是很好用。zsh的更多功能,请参考我的参考文献哈。

但是这样重新打开terminal的时候,你会发现没有提示了,这个时候我们需要在zshrc中加入source操作

vim ~/.zshrc

找个空地方把下面的配置添加上去
# Load zsh-autosuggestions.
source ~/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh

:wq保存退出,然后重新打开的时候就可以自动提示了

我的zshrc文件配置为:

# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH

# Path to your oh-my-zsh installation.
  export ZSH="/home/wu/.oh-my-zsh"

# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes
ZSH_THEME="robbyrussell"


plugins=(
  git
)


# Load zsh-autosuggestions.
source ~/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh


source $ZSH/oh-my-zsh.sh

# User configuration

# export MANPATH="/usr/local/man:$MANPATH"

# You may need to manually set your language environment
# export LANG=en_US.UTF-8

# Preferred editor for local and remote sessions
# if [[ -n $SSH_CONNECTION ]]; then
#   export EDITOR='vim'
# else
#   export EDITOR='mvim'
# fi

# Compilation flags
# export ARCHFLAGS="-arch x86_64"

# ssh
# export SSH_KEY_PATH="~/.ssh/rsa_id"

# Set personal aliases, overriding those provided by oh-my-zsh libs,
# plugins, and themes. Aliases can be placed here, though oh-my-zsh
# users are encouraged to define aliases within the ZSH_CUSTOM folder.
# For a full list of active aliases, run `alias`.
#
# Example aliases
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"

3.zsh-autosuggestions Mac安装 

mac可以使用brew进行安装:

brew install zsh-autosuggestions

然后把下面的zsh生效的命令,加入环境变量配置文件.zshrc中就行了

vim ~/.zshrc

source $HOMEBREW_PREFIX/share/zsh-autosuggestions/zsh-autosuggestions.zsh

:wq保存退出,然后重新打开的时候就可以自动提示了

参考文献

[1].zsh-autosuggestions.GitHub - zsh-users/zsh-autosuggestions: Fish-like autosuggestions for zsh

[2].Oh My ZSH.Oh My Zsh - a delightful & open source framework for Zsh

[3].终端自动提示插件的安装.shell - 终端自动提示插件的安装 - 前端专精 - SegmentFault 思否

[4].zsh-autosuggestions — Homebrew Formulae

评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

农民小飞侠

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值