zsh之oh-my-zsh主题配置

查看当前shell

echo $SHELL

zsh

安装zsh

yum install -y zsh

查看zsh

# 查看安装 zsh
which zsh

# 查看 zsh 版本
zsh --version

#查看支持的shell
cat /etc/shells


zsh已添加到支持的shell

切换shellzsh

# 切换zsh shelll
chsh -s /bin/zsh

#重新查看目前默认的shell,已经变为bin/zsh
echo $SHELL

注意:

  • centos需要重启生效
  • .bash_profileBash中如有定制的设定时需要迁移至.zshrc文件中。

可以看到此时root用户的交互shell已经发生变化

cat /etc/passwd |grep '^root'
root:x:0:0:root:/root:/bin/zsh

oh-my-zsh

oh-my-zsh 帮我们整理了一些常用的 Zsh 扩展功能和主题,避免重复造轮子,这里使用oh-my-zsh

安装 oh-my-zsh

# githu 访问较慢
wget https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh
sh install.sh
# 或
wget https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O - | sh


# gitee (国内建议)
wget https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh
sh install.sh

我这里使用gitee下载

[root@izgx8m1d9xjzhjz]~# wget https://gitee.com/mirrors/oh-my-zsh/raw/master/tools/install.sh
--2021-01-15 12:14:15--  https://gitee.com/mirrors/oh-my-zsh/raw/master/tools/install.sh
Resolving gitee.com (gitee.com)... 180.97.125.228
Connecting to gitee.com (gitee.com)|180.97.125.228|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/plain]
Saving to: ‘install.sh’

    [ <=>                                                                                                                                       ] 9,825       --.-K/s   in 0s      

2021-01-15 12:14:15 (50.8 MB/s) - ‘install.sh’ saved [9825]

[root@izgx8m1d9xjzhjz]~# ls
install.sh

然后给install.sh添加权限:

#install.sh添加权限
chmod +x install.sh

# 执行
./install.sh

如果发现很慢,可以修改为gitee源,编辑install.sh

默认设置

ZSH=${ZSH:-~/.oh-my-zsh}
REPO=${REPO:-ohmyzsh/ohmyzsh}
REMOTE=${REMOTE:-https://github.com/${REPO}.git}
BRANCH=${BRANCH:-master}

将中间两行改为:

REPO=${REPO:-mirrors/oh-my-zsh}
REMOTE=${REMOTE:-https://gitee.com/${REPO}.git}

重新执行即可。

安装成功

[root@izgx8m1d9xjzhjz]~# vim install.sh 
[root@izgx8m1d9xjzhjz]~# chmod +x install.sh
[root@izgx8m1d9xjzhjz]~# ./install.sh 
Cloning Oh My Zsh...
Cloning into '/root/.oh-my-zsh'...
remote: Enumerating objects: 1188, done.
remote: Counting objects: 100% (1188/1188), done.
remote: Compressing objects: 100% (1166/1166), done.
remote: Total 1188 (delta 23), reused 399 (delta 6), pack-reused 0
Receiving objects: 100% (1188/1188), 824.45 KiB | 0 bytes/s, done.
Resolving deltas: 100% (23/23), done.

Looking for an existing zsh config...
Using the Oh My Zsh template file and adding it to ~/.zshrc.

         __                                     __
  ____  / /_     ____ ___  __  __   ____  _____/ /_
 / __ \/ __ \   / __ `__ \/ / / /  /_  / / ___/ __ \
/ /_/ / / / /  / / / / / / /_/ /    / /_(__  ) / / /
\____/_/ /_/  /_/ /_/ /_/\__, /    /___/____/_/ /_/
                        /____/                       ....is now installed!


Before you scream Oh My Zsh! please look over the ~/.zshrc file to select plugins, themes, and options.

? Follow us on Twitter: https://twitter.com/ohmyzsh
? Join our Discord server: https://discord.gg/ohmyzsh
? Get stickers, shirts, coffee mugs and other swag: https://shop.planetargon.com/collections/oh-my-zsh

?  ~ 

配置 zsh 主题ys

vim ~/.zshrc

修改主题:
ZSH_THEME="robbyrussell"
#改为
ZSH_THEME="ys"
修改插件:
plugins=(git)
#改为
plugins=(git zsh-syntax-highlighting zsh-autosuggestions)

如果.bash_profile中有配置内容的话,还需要增加一行:

source ~/.bash_profile
更新配置文件

source .zshrc

发现同上报错是正常的,因为我们还没有下载插件,直接就配置了。

安装插件
安装zsh-syntax-highlighting
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
安装zsh-autosuggestions
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

安装完成后,重新更新配置:

source .zshrc

在编辑指令的时候,对于之前使用过的指令,按Tab键即可快速补全,非常好用。

配置zsh主题 powerlevel9k (推荐)

安装
$ git clone https://github.com/bhilburn/powerlevel9k.git ~/.oh-my-zsh/custom/themes/powerlevel9k

编辑 ~/.zshrc来启用主题,在其中将ZSH_THEME 改为

ZSH_THEME="powerlevel9k/powerlevel9k"

如果你还没有安装字体,那么可以使用下面的命令来安装所需字体。

安装 powerline字体
# 下载
git clone https://github.com/powerline/fonts.git

# 进入文件夹并安装
cd fonts
./install.sh
安装 Awesome-Terminal Fonts字体
git clone https://github.com/gabrielelana/awesome-terminal-fonts.git
cd awesome-terminal-fonts
./install.sh
安装nerd-fonts
#下载
git clone https://github.com/ryanoasis/nerd-fonts.git
#安装同上


修改配置文件.zshrc

#Path to your oh-my-zsh installation.
export TERM="xterm-256color"
export ZSH="/root/.oh-my-zsh"

#default
#ZSH_THEME="robbyrussell"
#ZSH_THEME="ys"
ZSH_THEME="powerlevel9k/powerlevel9k"

plugins=(git zsh-autosuggestions)
#plugins=(git zsh-syntax-highlighting zsh-autosuggestions)

source $ZSH/oh-my-zsh.sh                                                                                                                                                    
  • 9
    点赞
  • 26
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 8
    评论
oh-my-zsh 是一个开源的、社区驱动的 zsh 配置管理框架,它提供了一系列的插件、主题和自定义选项,使得用户可以轻松地定制和管理自己的 zsh 终端环境。它旨在提供一个更强大、更易用的终端工具。 而 oh-my-zsh-git 是 oh-my-zsh 在 GitHub 上的一个 fork 版本,它基于原版的 oh-my-zsh,对其进行了一些修改和扩展。oh-my-zsh-git 主要的目的是为了扩展和增强原版 oh-my-zsh 的功能,并从社区中收集和整合更多的插件和主题。 具体来说,oh-my-zsh-git 与 oh-my-zsh 的区别主要体现在以下几个方面: 1. 功能扩展:oh-my-zsh-git 在原版 oh-my-zsh 的基础上增加了一些功能和工具,使得终端使用起来更加方便和高效。 2. 插件和主题oh-my-zsh-git 提供了更多的插件和主题选项,且会持续更新和增加。用户可以根据自己的需求选择和使用不同的插件和主题。 3. 扩展性:oh-my-zsh-git 更加注重可扩展性,用户可以自定义添加新的插件和主题,或者根据自己的需要修改现有的插件和主题。 4. 社区支持:oh-my-zsh-git 的社区活跃度较高,用户能够得到更多的帮助和支持,同时也能够贡献自己的代码和改进。 综上所述,oh-my-zsh-git 是在 oh-my-zsh 基础上进行的一些改进和扩展,提供了更多的插件和主题选项,同时注重用户的自定义和扩展能力。用户可以根据自己的需求选择采用哪个版本。
评论 8
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

DuebassLei

请我吃颗棒棒糖吧~~

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

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

打赏作者

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

抵扣说明:

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

余额充值