centos7安装zsh和自动补全插件

zsh是一个非常好用的shell,可以根据使用者的喜好和习惯来选择shell结构,让你的shell更美观。

一、安装zsh

  1. 安装zsh包
sudo yum install zsh -y
  1. zsh安装完成后,把系统默认的shell由bash切换为zsh:
chsh -s /bin/zsh  #
  1. 切换后查询一下当前系统的shell
echo $SHELL

如果输出结果为

/bin/bash

说明没有切换过来,可以通过重启服务器以生效。

sudo reboot

二、安装oh-my-zsh

  1. 从gitee下载install.sh
wget https://gitee.com/mirrors/oh-my-zsh/raw/master/tools/install.sh
  1. 将install.sh中仓库修改为gitee地址
sed -i 's/REPO=${REPO:-ohmyzsh/ohmyzsh}/REPO=${REPO:-mirrors/oh-my-zsh}/' install.sh
sed -i 's/REMOTE=${REMOTE:-https://github.com/${REPO}.git}/REMOTE=${REMOTE:-https://gitee.com/${REPO}.git}/' install.sh
  1. 更改install.sh权限
chmod +x install.sh
  1. 执行install.sh
./install.sh

出现以下内容说明安装成功。
在这里插入图片描述

  1. 打开~/.zshrc文件,修改主题ZSH_THEME
ZSH_THEME="af-magic"

可以根据自己的喜好来更换主题

3den.zsh-theme           dst.zsh-theme              itchy.zsh-theme           mira.zsh-theme                  skaro.zsh-theme
adben.zsh-theme          duellj.zsh-theme           jaischeema.zsh-theme      mlh.zsh-theme                   smt.zsh-theme
af-magic.zsh-theme       eastwood.zsh-theme         jbergantine.zsh-theme     mortalscumbag.zsh-theme         Soliah.zsh-theme
afowler.zsh-theme        edvardm.zsh-theme          jispwoso.zsh-theme        mrtazz.zsh-theme                sonicradish.zsh-theme
agnoster.zsh-theme       emotty.zsh-theme           jnrowe.zsh-theme          murilasso.zsh-theme             sorin.zsh-theme
alanpeabody.zsh-theme    essembeh.zsh-theme         jonathan.zsh-theme        muse.zsh-theme                  sporty_256.zsh-theme
amuse.zsh-theme          evan.zsh-theme             josh.zsh-theme            nanotech.zsh-theme              steeef.zsh-theme
apple.zsh-theme          fino-time.zsh-theme        jreese.zsh-theme          nebirhos.zsh-theme              strug.zsh-theme
arrow.zsh-theme          fino.zsh-theme             jtriley.zsh-theme         nicoulaj.zsh-theme              sunaku.zsh-theme
aussiegeek.zsh-theme     fishy.zsh-theme            juanghurtado.zsh-theme    norm.zsh-theme                  sunrise.zsh-theme
avit.zsh-theme           flazz.zsh-theme            junkfood.zsh-theme        obraun.zsh-theme                superjarin.zsh-theme
awesomepanda.zsh-theme   fletcherm.zsh-theme        kafeitu.zsh-theme         oldgallois.zsh-theme            suvash.zsh-theme
bira.zsh-theme           fox.zsh-theme              kardan.zsh-theme          peepcode.zsh-theme              takashiyoshida.zsh-theme
blinks.zsh-theme         frisk.zsh-theme            kennethreitz.zsh-theme    philips.zsh-theme               terminalparty.zsh-theme
bureau.zsh-theme         frontcube.zsh-theme        kiwi.zsh-theme            pmcgee.zsh-theme                theunraveler.zsh-theme
candy-kingdom.zsh-theme  funky.zsh-theme            kolo.zsh-theme            pygmalion-virtualenv.zsh-theme  tjkirch_mod.zsh-theme
candy.zsh-theme          fwalch.zsh-theme           kphoen.zsh-theme          pygmalion.zsh-theme             tjkirch.zsh-theme
clean.zsh-theme          gallifrey.zsh-theme        lambda.zsh-theme          random.zsh-theme                tonotdo.zsh-theme
cloud.zsh-theme          gallois.zsh-theme          linuxonly.zsh-theme       re5et.zsh-theme                 trapd00r.zsh-theme
crcandy.zsh-theme        garyblessington.zsh-theme  lukerandall.zsh-theme     refined.zsh-theme               wedisagree.zsh-theme
crunch.zsh-theme         gentoo.zsh-theme           macovsky-ruby.zsh-theme   rgm.zsh-theme                   wezm+.zsh-theme
cypher.zsh-theme         geoffgarside.zsh-theme     macovsky.zsh-theme        risto.zsh-theme                 wezm.zsh-theme
dallas.zsh-theme         gianu.zsh-theme            maran.zsh-theme           rixius.zsh-theme                wuffers.zsh-theme
darkblood.zsh-theme      gnzh.zsh-theme             mgutz.zsh-theme           rkj-repos.zsh-theme             xiong-chiamiov-plus.zsh-theme
daveverwer.zsh-theme     gozilla.zsh-theme          mh.zsh-theme              rkj.zsh-theme                   xiong-chiamiov.zsh-theme
dieter.zsh-theme         half-life.zsh-theme        michelebologna.zsh-theme  robbyrussell.zsh-theme          ys.zsh-theme
dogenpunk.zsh-theme      humza.zsh-theme            mikeh.zsh-theme           sammy.zsh-theme                 zhann.zsh-theme
dpoggi.zsh-theme         imajes.zsh-theme           miloshadzic.zsh-theme     simonoff.zsh-theme
dstufft.zsh-theme        intheloop.zsh-theme        minimal.zsh-theme         simple.zsh-theme

也可以在官网直接查看效果
https://github.com/ohmyzsh/ohmyzsh/wiki/Themes

三、安装zsh-autosuggestions插件

zsh-autosuggestions是一个自动补全插件,可以记录你的输入历史,推测你想输入的内容,是个非常便捷好用的插件。

  1. 克隆镜像到本地
git clone https://gitee.com/hailin_cool/zsh-autosuggestions.git $ZSH_CUSTOM/plugins/zsh-autosuggestions
  1. 打开zshrc文件
vi ~/.zshrc

在.zshrc里面找到plugins,在后面加上zsh-autosuggestions

plugins=(git zsh-autosuggestions)

保存退出,更新~/.zshrc文件

source ~/.zshrc

安装完成