Oh-My-Zsh 安装(Linux 终端美化)

个人学习记录笔记


Oh-My-Zsh 安装(Linux 终端美化)

官网:Oh-My-Zsh

起步安装

基于Ubuntu (不同发行版大同小异)

查看当前终端

# 查看当前 shell
echo $SHELL
# 查看系统自带的 shell
cat /etc/shells

安装 Zsh 终端

# 安装
sudo apt install zsh
# 命令查看当前系统中全部shell中出现zsh则代表安装成功
cat /etc/shells

# 配置 shell
# 设置zsh为默认shell
chsh -s /bin/zsh
reboot

下载 Oh My Zsh

# github 源
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
# gitee 镜像源
sh -c "$(curl -fsSL https://gitee.com/mirrors/oh-my-zsh/raw/master/tools/install.sh)"

# 可用wget
sh -c "$(wget https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O -)"

若未安装 Git 需要先安装 git 工具

不同系统下载参考:Download for Linux and Unix

sudo apt install git

美化

主题预览 https://github.com/ohmyzsh/ohmyzsh/wiki/themes

查看本地主题列表(安装时默认自带一些主题)

主题文件默认放在 ~/.oh-my-zsh/themes 即当前用户文件夹的根目录下

cd ~/.oh-my-zsh/themes && ls

设置主题

设置主题样式的配置主要在 ~/.zshrc 即用户的根目录下的 .zshrc 文件中进行配置
只需要找到如下图所示的位置将红色方框处的文本修改即可实现主题设置

在这里插入图片描述

设置固定主题
# 只需要将文本修改为所需要的主题名称
ZSH_THEME="robbyrussell"
设置随机主题
# 只要设置为 random 即可
ZSH_THEME="random"

每次启动终端会输出以下内容,则说明此时为随即主题模式

[oh-my-zsh] Random theme 'jreese' loaded

推荐主题(个人向)

默认主题(robbyrussell)

个人感觉还可以

Powerlevel10k

仓库地址 https://github.com/romkatv/powerlevel10k

下载

git clone --depth=1 https://github.com/romkatv/powerlevel10k.git $ZSH_CUSTOM/themes/powerlevel10k

echo 'source $ZSH_CUSTOM/themes/powerlevel10k/powerlevel10k.zsh-theme' >>~/.zshrc
exec zsh

配置
按上述操作后第一次启动会进入配置脚本,按个人喜好进行配置即可;配置向导~/.p10k.zsh

补全图标;安装对应字体
参考文档 手动字体安装

AgnosterZak

仓库地址 https://github.com/zakaziko99/agnosterzak-ohmyzsh-theme

下载到本地后,将主题文件拷贝至 主题文件夹

# 示例
mv ~/Downloads/agnosterzak.zsh-theme $ZSH_CUSTOM/themes/

启用主题

# 修改配置文件
ZSH_THEME="agnosterzak"
# 重启终端
exec zsh

由于缺少字库因此会显示很奇怪
这个主题需要安装字体库 仓库地址 Powerline fonts

# 快速安装
sudo apt install fonts-powerline
# 在ubuntu 上支持 powerline 不支持的 unicode 字符
sudo apt install ttf-ancient-fonts 

插件扩展

插件使用说明以及支持插件列表: oh-my-zsh wiki plugins

推荐插件(个人向)

插件列表

plugins=(
    zsh-syntax-highlighting # 高亮
    zsh-autosuggestions # 自动
    git # git
    extract  # 解压
)
zsh-syntax-highlighting

仓库地址 https://github.com/zsh-users/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

仓库地址 https://github.com/zsh-users/zsh-autosuggestions

git clone https://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions
git

仓库地址 https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/git

extract

仓库地址 https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/extract

参考

Oh-My-Zsh 官网
Oh-My-Zsh 官方Wiki

Windows 平台基于 PowerShell 的终端美化(相应速度不如Linux,体验较差)
Oh-My-Posh 官网

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值