安装 Zsh Ubuntu 在 Ubuntu 18.04 LTS 上安装 Z-shell (Oh My Zsh)

2025-05-25

安装 Zsh Ubuntu在 Ubuntu 18.04 LTS 上安装 Z-shell (Oh My Zsh)

Ubuntu 的 Z-shell

  • 更新软件包
sudo apt-get update
sudo apt upgrade
Enter fullscreen mode Exit fullscreen mode
  • 安装必备软件包(ZSH、powerline 和 powerline 字体)
sudo apt install zsh
sudo apt-get install powerline fonts-powerline
Enter fullscreen mode Exit fullscreen mode
  • 克隆 Oh My Zsh Respo
git clone https://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh
Enter fullscreen mode Exit fullscreen mode
  • 创建新的 ZSH 配置文件
cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
Enter fullscreen mode Exit fullscreen mode
  • 为您的终端设置一个花式主题 -.zshrc使用 nano 编辑器打开文件
nano .zshrc
Enter fullscreen mode Exit fullscreen mode
  • 在文件中找到用主题ZSH_THEME="robbyrussell"替换的(CTRL + X&Enter 保存)robbyrussellagnoster.zshrc
ZSH_THEME="agnoster"
Enter fullscreen mode Exit fullscreen mode
  • 更改默认 Shell
chsh -s /bin/zsh
Enter fullscreen mode Exit fullscreen mode
cd .oh-my-zsh
upgrade_oh_my_zsh
Enter fullscreen mode Exit fullscreen mode

想要语法高亮?为 Oh My Zsh 安装 ZSH 语法高亮

  • 克隆 ZSH 语法高亮
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git "$HOME/.zsh-syntax-highlighting" --depth 1
Enter fullscreen mode Exit fullscreen mode
  • .zshrc在配置中添加语法高亮
echo "source $HOME/.zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" >> "$HOME/.zshrc"
Enter fullscreen mode Exit fullscreen mode

恢复默认 Shell

chsh -s /bin/bash
Enter fullscreen mode Exit fullscreen mode
文章来源:https://dev.to/mskian/install-z-shell-oh-my-zsh-on-ubuntu-1804-lts-4cm4
PREV
命名 API 端点的最佳实践
NEXT
作为一名开发者如何应对焦虑和抑郁