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"

 

参考文献

[1].zsh-autosuggestions.https://github.com/zsh-users/zsh-autosuggestions

[2].Oh My ZSH.https://ohmyz.sh/

[3].终端自动提示插件的安装.https://segmentfault.com/a/1190000003855641

你可能感兴趣的:(linux学习)