Linux Centos7.6下安装zsh、oh-my-zsh、powerlevel10k美化终端

踩了无数的坑所以特意在此总结一下

1、安装git

sudo yum install -y git

2、安装zsh

如果你centos版本为7x,那就无法自动安装zsh,后续安装的p10K主题要求的zsh最低版本为5.1,而7x所安装的是5.0;所以在此需要手动编译源码后安装zsh
这里选择zsh 5.8版本

①、clone zsh

我这里是干净的机器所以我就直接克隆,如果你已经安装过zsh了那么需要先删除(yum remove zsh)原来的后再手动安装
git clone -b zsh-5.8 --depth=1 https://github.com/zsh-users/zsh.git temp-zsh

②、安装所需要组件

sudo yum install git make ncurses-devel gcc autoconf man

③、安装

cd temp-zsh
./Util/preconfig
./configure
在这里插入图片描述

make
在这里插入图片描述

make check
在这里插入图片描述

make install
在这里插入图片描述

⑤、查看

在这里插入图片描述
将/usr/local/bin/zsh加入/etc/shells内
切换bash
chsh -s $(which zsh)

Options For Configure
---------------------

The `configure' program accepts many options, not all of which are useful
or relevant to zsh.  To get the complete list of configure options, run
"./configure --help".  The following list should contain most of the
options of interest for configuring zsh.

Configuration:
  --cache-file=FILE     # cache test results in FILE
  --help                # print a help message
  --version             # print the version of autoconf that create configure
  --quiet, --silent     # do not print `checking...' messages
  --no-create           # do not create output files

Directories:
  --prefix=PREFIX       # install host independent files in PREFIX [/usr/local]
  --exec-prefix=EPREFIX # install host dependent files in EPREFIX [PREFIX]
  --bindir=DIR          # install user executables in DIR [EPREFIX/bin]
  --infodir=DIR         # install info documentation in DIR [PREFIX/info]
  --mandir=DIR          # install man documentation in DIR [PREFIX/man]
  --srcdir=DIR          # find the sources in DIR [configure dir or ..]
  --datadir=DATADIR     # install shared files in DATADIR [PREFIX/share]

Features:
  --enable-FEATURE      # enable use of this feature
  --disable-FEATURE     # disable use of this feature

Here is the list of FEATURES currently supported.  Defaults are shown in
brackets, though a value shown as `yes' (equivalent to --enable-FEATURE)
will be ignored if your OS doesn't support that feature.

zsh-debug            # compile debugging features into zsh [no]
zsh-mem              # use zsh's memory allocators [no]
zsh-mem-debug        # debug zsh's memory allocators [no]
zsh-mem-warning      # turn on warnings of memory allocation errors [no]
zsh-secure-free      # turn on memory checking of free() [no]
zsh-hash-debug       # turn on debugging of internal hash tables [no]
etcdir=directory     # default directory for global zsh scripts [/etc]
zshenv=pathname      # the path to the global zshenv script [/etc/zshenv]
zshrc=pathname       # the path to the global zshrc script [/etc/zshrc]
zlogin=pathname      # the path to the global zlogin script [/etc/zlogin]
zprofile=pathname    # the path to the global zprofile script [/etc/zprofile]
zlogout=pathname     # the path to the global zlogout script [/etc/zlogout]
fndir=directory      # the directory where shell functions will go
                     # [DATADIR/zsh/VERSION/functions]
site-fndir=directory # the directory where site-specific functions can go
                     # [DATADIR/zsh/site-functions]
additional-path      # add directories to default function path [<none>]
function-subdirs     # if functions will be installed into subdirectories [no]
dynamic              # allow dynamically loaded binary modules [yes]
largefile            # allow configure check for large files [yes]
locale               # allow use of locale library [yes]

# 这是.configure不加选项生成的配置
zsh configuration
-----------------
zsh version               : 5.8
host operating system     : x86_64-pc-linux-gnu
source code location      : .
compiler                  : gcc
preprocessor flags        :
executable compiler flags :  -Wall -Wmissing-prototypes -O2
module compiler flags     :  -Wall -Wmissing-prototypes -O2 -fPIC
executable linker flags   :   -s -rdynamic
module linker flags       :   -s -shared
library flags             : -lgdbm -ldl -lncursesw -lrt -lm  -lc
installation basename     : zsh
binary install path       : /usr/local/bin
man page install path     : /usr/local/share/man
info install path         : /usr/local/share/info
functions install path    : /usr/local/share/zsh/5.8/functions
See config.modules for installed modules and functions.

3、安装oh-my-zsh

网上有的博客是直接wget github上的,但是有链接不稳定的情况,所以这里咱么你直接用国内的资源就好
gitee:https://gitee.com/sun_kuo_rui/fonts
这仓库放了安装p10k的所需字体和安装oh-my-zsh所需的install.sh
在这里执行./install.sh
执行完成后出现一下内容证明安装成功
在这里插入图片描述

插件安装

zsh-syntax-highlighting :提供了语法高亮显示。
zsh-autosuggestions :它会根据历史记录和完成情况建议您键入的命令,而且快速/不干扰自动提示。
zsh-completions :命令自动补全。

采用国内下载源
git clone https://gitee.com/mo2/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting

git clone https://gitee.com/yantaozhao/zsh-autosuggestions.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

git clone https://gitee.com/wangnd/zsh-completions.git ${ZSH_CUSTOM:=~/.oh-my-zsh/custom}/plugins/zsh-completions

修改.zshrc

在这里插入图片描述

在这里插入图片描述
source .zshrc
到这里其实已经比Linux原来的操作界面好看多了,但是zsh虽有好多theme但是还是有些枯燥,所以这里继续安装p10k使终端不在枯燥,提高开发效率

5、安装powerlevel10k

因为咱么手动安装的zsh所以zsh的版本完全符合powerlevel10k的要求。
在安装前需要安装四个powerlevel10k所需字体(我的gitee中有可以直接用https://gitee.com/sun_kuo_rui/fonts.git), 其实安装步骤powerlevel10k git上都有
https://github.com/romkatv/powerlevel10k

①、安装字体

执行完该指令后就可以看到fonts和fontconfig目录了(有的服务器可能没带所以需要安装)
yum -y install fontconfig
将字体上传此目录
cd /usr/share/fonts/
在这里插入图片描述
刷新内存中的字体缓存,这样就不用reboot重启了
fc-cache
fc-list查看是否安装成功
在这里插入图片描述

②、安装p10k

git clone --depth=1 https://gitee.com/romkatv/powerlevel10k.git KaTeX parse error: Expected '}', got 'EOF' at end of input: {ZSH_CUSTOM:-HOME/.oh-my-zsh/custom}/themes/powerlevel10k
修改.zshrc中的theme Set ZSH_THEME=“powerlevel10k/powerlevel10k” in ~/.zshrc.
在这里插入图片描述
source ./zshrc
下面按照引导慢慢配置就好了,主要是一些p10k风格的问题
在这里插入图片描述完成拉
在这里插入图片描述还可以通过修改.p10k.zsh来拓展powerlevel10k的样式,将内容直接复制翻译就明白了每个代表了啥意思了,修改完后记得source .zshrc

  • 5
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要在CentOS 7上安装oh-my-zsh,可以按照以下步骤进行操作: 1. 首先,你需要安装zsh和git。可以使用以下命令安装它们: ``` sudo yum install zsh git ``` 2. 安装完成后,你可以使用以下命令将zsh设置为默认的Shell: ``` chsh -s /bin/zsh ``` 输入你的密码后,按照提示选择zsh。 3. 然后,使用git克隆oh-my-zsh的仓库。可以使用以下命令进行克隆: ``` git clone https://github.com/ohmyzsh/ohmyzsh.git ~/.oh-my-zsh ``` 4. 克隆完成后,你可以将oh-my-zsh的配置文件复制到你的家目录下: ``` cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc ``` 5. 接下来,你可以编辑你的.zshrc文件,设置主题和插件。你可以使用任何你喜欢的主题,比如dracula主题。可以使用以下命令将主题文件复制到oh-my-zsh的themes目录下: ``` mv zsh-master/dracula.zsh-theme ~/.oh-my-zsh/themes/ ``` 6. 最后,你需要重新登录或者使用以下命令使设置生效: ``` source ~/.zshrc ``` 现在,你已经成功地在CentOS 7上安装oh-my-zsh。你可以根据个人喜好进一步自定义和配置zsh。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [Centos7-Linux安装zshoh-my-zsh(内含国内安装方法)](https://blog.csdn.net/qimowei/article/details/119517167)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* *3* [centos7 安装和使用oh-my-zsh](https://blog.csdn.net/shinlj/article/details/102719016)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值