NipGeihou's blog NipGeihou's blog
  • Java

    • 开发规范
    • 进阶笔记
    • 微服务
    • 快速开始
    • 设计模式
  • 其他

    • Golang
    • Python
    • Drat
  • Redis
  • MongoDB
  • 数据结构与算法
  • 计算机网络
  • 应用

    • Grafana
    • Prometheus
  • 容器与编排

    • KubeSphere
    • Kubernetes
    • Docker Compose
    • Docker
  • 组网

    • TailScale
    • WireGuard
  • 密码生成器
  • 英文单词生成器
🍳烹饪
🧑‍💻关于
  • 分类
  • 标签
  • 归档

NipGeihou

我见青山多妩媚,料青山见我应如是
  • Java

    • 开发规范
    • 进阶笔记
    • 微服务
    • 快速开始
    • 设计模式
  • 其他

    • Golang
    • Python
    • Drat
  • Redis
  • MongoDB
  • 数据结构与算法
  • 计算机网络
  • 应用

    • Grafana
    • Prometheus
  • 容器与编排

    • KubeSphere
    • Kubernetes
    • Docker Compose
    • Docker
  • 组网

    • TailScale
    • WireGuard
  • 密码生成器
  • 英文单词生成器
🍳烹饪
🧑‍💻关于
  • 分类
  • 标签
  • 归档
  • Linux

    • CentOS

    • Ubuntu

    • 环境安装

    • 常用命令

    • 常用软件

    • 最佳实践

    • 通用

      • 磁盘管理与文件系统
      • Oh My ZSH
        • 简介
          • 特点
          • Zsh 与 Oh My ZSH
        • 安装 ZSH
        • 安装 Oh My ZSH
        • 安装主题 Powerlevel10k
        • 插件
          • aliases - 别名备忘单
          • sudo
          • history
          • systemd
          • ansible
        • 参考
      • 开启BBR
      • Shell笔记
  • Docker

  • 云原生

  • Kubernetes

  • KubeSphere

  • K3S

  • 笔记

  • PVE

  • 维修

  • DevOps

  • 云服务

  • 路由器

  • Hyper-V

  • Windows

  • macOS

  • 运维
  • Linux
  • 通用
NipGeihou
2023-06-03
目录

Oh My ZSH

# 简介

  • 官网:https://ohmyz.sh/ (opens new window)
  • 仓库:https://github.com/ohmyzsh/ohmyzsh (opens new window)

Shell 与 Sh 的关系 Shell 是抽象类,Sh、Bash、Zsh 是实现。

为什么要用 Zsh 而不用 Bash?

  • Bash 于 1989 年首次发布,它是大多数 Linux 发行版的默认 Shell 环境。其他发行版,如 Kali Linux,使用 Z Shell 作为默认 shell。
  • Z Shell 又称 Zsh,在 Bash 的基础上改了改进(不完全兼容 Bash),macOS 默认使用 Zsh Shell。

# 特点

  • 支持内联通配符表达式
  • 比 Bash 可配置度更高
  • 支持插件和主题:插件清单 (opens new window)

# Zsh 与 Oh My ZSH

Oh My ZSH 不是 Shell,是一种管理 Zsh 配置的方式

# 安装 ZSH

# 查看当前shell
echo $SHELL

# 安装
apt install zsh

# 查看版本
zsh --version

# 设置为当前用户的默认shell
chsh -s $(which zsh)

# 退出 重新登录
exit
  • 再次打开会引导配置 ~/.zshrc 配置文件,现在输入 0 创建一个空的即可。
  • 至此安装完成,再次检查当前 Shell: echo $SHELL

# 安装 Oh My ZSH

# 依赖;但通常都有的
apt install zsh curl git 

# 互联网
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

# 国内
sh -c "$(curl -fsSL https://install.ohmyz.sh/)"
  • 看到彩色的 Oh My ZSH 字样,说明已成功安装。

# 安装主题 Powerlevel10k

image.png

romkatv/powerlevel10k: A Zsh theme (opens new window)

# 安装 - Github
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

# 安装好后,编辑~/.zshrc
nano ~/.zshrc

# 将 ZSH_THEME 的值修改为 powerlevel10k/powerlevel10k
ZSH_THEME="powerlevel10k/powerlevel10k"

  • 同时为了有更佳的体验,主题作者推荐安装 MesloLGS NF 字体并在终端中设置。详细参考 Github 仓库页 Manual font installation (opens new window) 内容。
  • 退出会话,重新打开
  • 根据引导按自己喜好配置主题。
  • 如需重新配置 p10k configure
引导页面没有出现 Rainbow Style 样式选择页面

连接的终端不支持时则不会出现,如 MobaXterm 就不会出现,Tabby 正常显示

# 插件

  • 插件列表(不完整):Plugins Overview · ohmyzsh/ohmyzsh Wiki (opens new window)
  • ohmyzsh/plugins at master · ohmyzsh/ohmyzsh (opens new window)
nano ~/.zshrc

# .zshrc 找到 plugins
plugins=(git)

# 默认使用了git,如需使用其他插件,如aliases、sudo
plugins=(git aliases sudo)


# 重新加载
source ~/.zshrc

我的插件

plugins=(git aliases sudo history systemd ansible)

# aliases - 别名备忘单

ohmyzsh/plugins/aliases at master · ohmyzsh/ohmyzsh (opens new window)

# 按组显示所有别名
als 

# 关键字过滤
als <keyword(s)>
#als git

常用别名


# sudo

按两下 ESC 为当前或上一条命令添加 sudo

apt update + 按2下ESC => sudo apt update

# history

ohmyzsh/plugins/history at master · ohmyzsh/ohmyzsh (opens new window)

h = history
hl = history | less
hs = history | grep
hsi = history | grep -i

# systemd

ohmyzsh/plugins/systemd at master · ohmyzsh/ohmyzsh (opens new window)

sc-start= = =sudo systemctl start 
sc-stop = sudo systemctl stop
sc-reload = sudo systemctl reload 
sc-restart = sudo systemctl restart 
sc-try-restart = sudo systemctl try-restart

# ansible

ohmyzsh/plugins/ansible at master · ohmyzsh/ohmyzsh (opens new window)

a = ansible
aconf = ansible-config
aplaybook = ansible-playbook

# 参考

  • Upgrade your Terminal NOW | How to install ZSH, oh-my-zsh, themes and plugins - YouTube (opens new window)
上次更新: 2024/11/28, 17:59:33
磁盘管理与文件系统
开启BBR

← 磁盘管理与文件系统 开启BBR→

最近更新
01
iSCSI服务搭建
05-10
02
磁盘管理与文件系统
05-02
03
网络测试 - iperf3
05-02
更多文章>
Theme by Vdoing | Copyright © 2018-2025 NipGeihou | 友情链接
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式