Ubuntu 配置 Oh-My-Zsh

安装 Zsh:

1
2
sudo apt update
sudo apt install zsh

将 Zsh 设置为默认 Shell :

1
chsh -s /bin/zsh

查看当前所用的 Shell : echo $SHELL

安装 Oh My Zsh :
以下 3 种方式选择 1 种:

  • via wget
1
sh -c "$(wget -O- https://raw.GitHubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
  • via curl
1
sh -c "$(curl -fsSL https://raw.GitHubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
  • Manual
1
2
curl -Lo install.sh https://raw.GitHubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh
sh install.sh

字体可以安装 Powerline ,但是推荐安装符号更全的 Ubuntu Nerd Font 或者 Knack Nerd Font Mono。在 Guake 里设置好。

下载:Ubuntu Nerd Font
下载:Knack Nerd Font Mono

下载后直接安装字体即可。

安装主题 Powerlevel9k :

1
git clone https://github.com/bhilburn/powerlevel9k.git ~/.oh-my-zsh/custom/themes/powerlevel9k

安装插件:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# autojump 切换目录
sudo apt install autojump
    
# fasd 快速访问文件或目录
sudo apt install fasd
    
# zsh-autosuggestions 历史命令建议
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
    
# zsh-syntax-highlighting 命令行语法高亮
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting

设置 Oh My Zsh :

1
vi ~/.zshrc

需要修改如下几个地方:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
    ******
POWERLEVEL9K_MODE='nerdfont-complete'
ZSH_THEME="powerlevel9k/powerlevel9k"
    ******
ENABLE_CORRECTION="true"
    ******
COMPLETION_WAITING_DOTS="true"
    ******
plugins=( git extract fasd zsh-autosuggestions zsh-syntax-highlighting docker docker-compose )
    ******

让配置生效:

1
source ~/.zshrc
Pre-generated by ChatGPT 3.5
这篇文章介绍了配置Ubuntu操作系统的Oh-My-Zsh工具。文章介绍了安装Zsh和将其设置为默认的Shell,然后详细介绍了Oh My Zsh的安装过程。作者提供了三种安装方式供选择,并建议安装Powerline字体、Ubuntu Nerd Font或Knack Nerd Font Mono以获得更好的显示效果。另外,文章还介绍了安装并设置主题Powerlevel9k以及一些插件,最后还提到了一些需要修改的配置项和使配置生效的方法。