linux zsh终端美化

目前的centos系统默认的shell还是bash,但是zsh被称为终极shell,国外有个程序员开发出了一个能够让你快速上手的zsh项目,叫做「oh my zsh」,Github 网址是:https://github.com/robbyrussell/oh-my-zsh 有了这玩意zsh用起来直接就变成神器了。

查看系统当前的shell

echo $SHELL

返回的结果是:

/bin/bash

查看bin下是否有zsh包

cat /etc/shells
**********************************************
返回的结果是:
/bin/sh
/bin/bash
/sbin/nologin
/usr/bin/sh
/usr/bin/bash
/usr/sbin/nologin

PS.默认没有安装zsh

zsh

安装

sudo yum install -y zsh

然后在输入cat /etc/shells查看

/bin/sh
/bin/bash
/sbin/nologin
/usr/bin/sh
/usr/bin/bash
/usr/sbin/nologin
/bin/zsh

配置

将zsh设置成默认的shell

chsh -s /bin/zsh

设置完以后不会立即生效,需要重启终端方能生效
查看版本

zsh --version
**********************************************
返回的结果是:
zsh 5.0.2 (x86_64-redhat-linux-gnu)

oh-my-zsh

安装

通过 GitHub安装容易出现安装失败的情况,所以我们采用 gitee 镜像仓库来安装

wget https://gitee.com/Devkings/oh_my_zsh_install/raw/master/install.sh -O - | sh

出现以下界面就表示安装成功了

         __                                     __
  ____  / /_     ____ ___  __  __   ____  _____/ /_
 / __ \/ __ \   / __ `__ \/ / / /  /_  / / ___/ __ \
/ /_/ / / / /  / / / / / / /_/ /    / /_(__  ) / / /
\____/_/ /_/  /_/ /_/ /_/\__, /    /___/____/_/ /_/
                        /____/                       ....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

执行命令source .zshrc 就可以显示oh-my-zsh的默认主题robbyrussell

~% source .zshrc
➜  ~ 

配置主题

可以通过ls .oh-my-zsh/themes查看当前可用主题,也可以去ohmyzsh 主题页预览效果

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

我比较喜欢的是agnoster这个主题
修改文件.zshrc

ZSH_THEME="agnoster"

更新配置文件

source .zshrc

就生效了
在这里插入图片描述

当然也可以参考推荐:Slant - What’s the best theme for Oh My Zsh?
最火的莫过于Powerlevel10 k 了,但是 zsh 必须是 5.1 以上版本

安装Powerlevel10k

手动安装

git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k

国内用户可以使用 gitee上的官方镜像加速下载.

git clone --depth=1 https://gitee.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k

Powerlevel10k 配置
编辑 .zshrc 文件, 文件路径 ~/.zshrc

vim ~/.zshrc
# 修改
ZSH_THEME="powerlevel10k/powerlevel10k"

Powerlevel10k 需要进行一些样式的设置,执行source .zshrc更新配置后,首次会进入样式设置引导,后期也可以通过命令

 p10k configure

去修改设置。

<think>好的,用户想美化Linux终端的外观、主题、配置和工具。我需要根据提供的引用内容和自己的知识来回答这个问题。首先,用户提供的引用里提到了oh-my-zsh,这是一个常用的工具,应该作为主要推荐。引用[1]中提到在.zshrc中配置插件,包括git、zsh-autosuggestions和zsh-syntax-highlighting,这些插件能提升用户体验,所以需要详细说明如何安装和配置。 另外,引用[2]提到终端美化对于经常使用终端的人很重要,可以提高效率。所以可能还需要推荐其他工具,比如powerlevel10k主题,它很受欢迎,配置起来也比较方便。还有starship,这是一个跨平台的提示符工具,适合不同shell的用户。 接下来,步骤需要分点说明,比如安装oh-my-zsh,配置主题,安装插件,其他工具推荐,字体安装等。每个步骤要具体,比如如何通过git克隆仓库,如何编辑.zshrc文件,如何安装插件管理器等。可能需要提到安装字体,因为有些主题需要特定的符号字体支持,比如Powerline或Nerd Fonts。 另外,用户可能遇到的问题,比如插件安装失败或者主题显示不正常,可能需要提示他们安装必要的依赖,比如zsh-syntax-highlighting和zsh-autosuggestions的安装方法。还要注意是否需要重启终端或者重新加载配置。 最后,生成相关的问题,比如如何自定义主题,优化性能,或者颜色配置技巧。这些都需要自然地从回答中延伸出来。</think>### Linux终端美化方法详解 Linux终端美化主要通过配置框架、主题和插件实现,以下为详细操作步骤: 1. **安装oh-my-zsh框架** ```bash sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" ``` 该框架提供200+主题和插件支持,是终端美化的基础平台[^1] 2. **配置.zshrc主题** 在配置文件`~/.zshrc`中设置: ```bash ZSH_THEME="agnoster" # 推荐主题包括powerlevel10k、spaceship ``` 安装powerlevel10k主题: ```bash git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k ``` 3. **插件配置**(需先安装插件管理器) ```bash # 安装zsh插件管理器 git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions git clone https://github.com/zsh-users/zsh-syntax-highlighting ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting # 修改.zshrc配置 plugins=( git zsh-autosuggestions zsh-syntax-highlighting ) ``` 4. **字体安装**(解决特殊符号显示问题) ```bash # 安装Nerd Fonts字体 sudo apt install fonts-firacode ``` 5. **其他工具推荐** - **starship**:跨平台提示符工具 ```bash curl -sS https://starship.rs/install.sh | sh ``` - **lsd**:带图标和颜色的ls替代工具 ```bash sudo apt install lsd alias ls='lsd --group-dirs first' ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值