CentOS7 源码安装 zsh 及 配置 Oh my zsh

因为一些国内不能访问 github,所以本教程使用的 gitee 下载源文件。

环境#

Centos7 最小化安装环境

源码编译安装#

如果需要安装 powerlevel10k 则需要源码安装最新版本,yum源中的5.0.2版本是不支持的

yum -y install wget git gcc ncurses-devel
wget http://ftp.funet.fi/pub/unix/shells/zsh/zsh-5.8.tar.xz /opt/software
tar -xvf zsh-5.8.tar.xz

cd zsh-5.8
./configure
make && make install

# 将zsh加入/etc/shells
vim /etc/shells
# 添加:
/usr/local/bin/zsh

更改默认终端#

chsh -s /usr/local/bin/zsh

这时候打开终端软件,应该就会默认进入 zsh 了。

如果 shell 连接进入 bash 则需要重启一下系统

配置 oh-my-zsh#

  1. 从 gitee 拉取 oh-my-zsh

国内镜像源(每日更新一次)

git clone https://gitee.com/mirrors/oh-my-zsh.git ~/.oh-my-zsh
  1. 默认配置
cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc

安装插件#

zsh-syntax-highlighting 命令高亮插件#

git clone https://gitee.com/dawnwords/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting

zsh-autosuggestions 自动建议补全#

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

安装 autojump 目录跳转#

git clone https://gitee.com/gentlecp/autojump.git
cd autojump
./install.py

执行成功后将出现的代码复制到 .zshrc 末尾处,可能有少许差异,不生效则需要以下面模版进行修改。

vim ~/.zshrc
[[ -s /root/.autojump/etc/profile.d/autojump.sh ]] && . /root/.autojump/etc/profile.d/autojump.sh

插件配置#

同样是打开.zshrc文件,找到plugins=(git),在这里增加自己想要的插件即可,多个插件名称之间使用空格或者换行分开(不能使用逗号)。
vim ~/.zshrc

plugins=(
        git
        sudo
        zsh-autosuggestions
        zsh-syntax-highlighting
        autojump
)

每次修改完 .zshrc 都需要

source ~/.zshrc
posted @   白日醒梦  阅读(921)  评论(0编辑  收藏  举报
编辑推荐:
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
点击右上角即可分享
微信分享提示
主题色彩