Ubuntu 18.04.4 安装 zsh

安装环境

Ubuntu 18.04.4 LTS
apt 1.6.12 (amd64)
带有 sudo 权限的用户(或 root 用户)
安装过程

1、更新 apt
sudo apt update
2、安装 zsh 依赖
sudo apt install zsh
3、安装 Oh My Zsh
sh -c “$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)”
安装示例:
jiangzl@MyInst-01:~$ sh -c “$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)”
Cloning Oh My Zsh…
Cloning into ‘/home/jiangzl/.oh-my-zsh’…
remote: Enumerating objects: 1152, done.
remote: Counting objects: 100% (1152/1152), done.
remote: Compressing objects: 100% (1117/1117), done.
remote: Total 1152 (delta 19), reused 1096 (delta 19), pack-reused 0
Receiving objects: 100% (1152/1152), 771.42 KiB | 3.27 MiB/s, done.
Resolving deltas: 100% (19/19), done.
Looking for an existing zsh config…
Using the Oh My Zsh template file and adding it to ~/.zshrc.
Time to change your default shell to zsh:
Do you want to change your default shell to zsh? [Y/n] y
Changing the shell…
Password:
Shell successfully changed to ‘/usr/bin/zsh’.
         __                                     __
  ____  / /_     ____ ___  __  __   ____  _____/ /_
/ __ / __    / __ `__ / / / /  /_  / / ___/ __
/ /_/ / / / /  / / / / / / /_/ /    / /_(__  ) / / /
____/_/ /_/  /_/ /_/ /_/__, /    /___/____/_/ /_/
                        /____/                       ….is now installed!
Please look over the ~/.zshrc file to select plugins, themes, and options.
p.s. Follow us on https://twitter.com/ohmyzsh
p.p.s. Get stickers, shirts, and coffee mugs at https://shop.planetargon.com/collections/oh-my-zsh
4、安装 zsh-autosuggestions 插件
autosuggestions 是 zsh 的自动提示插件,可以自动提示已经输入过的命令,非常方便。此插件也可以不安装,但强烈建议安装
a、使用 git 下载 zsh-autosuggestions 插件到 ~/.oh-my-zsh/plugins 目录
➜  plugins git:(master) cd ~/.oh-my-zsh/plugins
示例:
➜  plugins git:(master) git clone git://github.com/zsh-users/zsh-autosuggestions
Cloning into ‘zsh-autosuggestions’…
remote: Enumerating objects: 11, done.
remote: Counting objects: 100% (11/11), done.
remote: Compressing objects: 100% (10/10), done.
remote: Total 2396 (delta 2), reused 3 (delta 1), pack-reused 2385
Receiving objects: 100% (2396/2396), 545.28 KiB | 481.00 KiB/s, done.
Resolving deltas: 100% (1533/1533), done.
注:此处需要 Ubuntu 上已经安装 git,如果没有安装,请先安装 git
sudo apt install git
b、配置 zsh-autosuggestions 插件
编辑 vi ~/.zshrc 文件,找到 plugins=(xxx) 这一行,添加 zsh-autosuggestions,如下示例
plugins=(git zsh-autosuggestions)
c、使用配置生效
source ~/.zshrc
3、将 shell 设置为 zsh,使用如下命令切换
如果你在安装 oh-my-zsh 的时候没有选择切换 shell 到 zsh,那么你需要执行如下命令来切换。
chsh -s /bin/zsh
安装完成~
安装验证

输入一个 git,已经提示了最近使用 git 的一条命令,只需要按一下方向键的右键即可完成此条命令的输入,非常方便:

附录

卸载 oh-my-zsh
uninstall_oh_my_zsh

You may also like...

发表评论

电子邮件地址不会被公开。 必填项已用*标注

%d 博主赞过: