一、安装Zsh

sudo apt install zsh

使其成为您的默认外壳

chsh -s $(which zsh)

注销并重新登录以使用新的默认外壳。
测试它是否与echo $SHELL一起工作。预期结果:/bin/zsh或类似

二、安装和配置powerlevel10k

1)字体

Powerlevel10k 不需要自定义字体,但可以利用它们(如果可用)。它适用于Nerd Fonts、Source Code Pro、Font Awesome、Powerline,甚至是默认系统字体。只有在使用Nerd Fonts时,才能使用完整的样式选项。

推荐字体:为 Powerlevel10k 修补的 Meslo Nerd 字体或者使用 Nerd Fonts 字体以支持图标和特殊字符

下载MesloLGS NF字体:
MesloLGS NF Regular.ttf
MesloLGS NF Bold.ttf
MesloLGS NF Italic.ttf
MesloLGS NF Bold Italic.ttf

下载 Nerd Fonts 版本的 Fira Code 字体
Fira Code Regular Nerd Font Complete

windows系统双击每个文件,然后单击“安装”。这将使MesloLGS NF字体可供所有人使用。
linux系统:
如果没有~/.local/share/fonts目录需要手动创建下

mkdir -p ~/.local/share/fonts

加载字体

fc-cache -vf ~/.local/share/fonts/

查看字体是否加载成功

$ fc-list | grep -i MesloLGS
显示结果:
/home/jjli/.local/share/fonts/MesloLGS NF Regular.ttf: MesloLGS NF:style=Regular
/home/jjli/.local/share/fonts/MesloLGS NF Bold Italic.ttf: MesloLGS NF:style=Bold Italic
/home/jjli/.local/share/fonts/MesloLGS NF Bold.ttf: MesloLGS NF:style=Bold
/home/jjli/.local/share/fonts/MesloLGS NF Regular (1).ttf: MesloLGS NF:style=Regular
/home/jjli/.local/share/fonts/MesloLGS NF Italic.ttf: MesloLGS NF:style=Italic

在终端配置中选择字体,使用MesloLGS NF Regular字体,否则终端中加载的图片有乱码。
f81187f7c9ef0648b60ff7d8aac634ef.png

系统上的应用程序。配置您的终端以使用此字体:

  • GNOME 终端(默认的 Ubuntu 终端):打开 Terminal → Preferences 并单击 Profiles 下的选定配置文件。勾选 Text Appearance 下的 Custom font 并选择MesloLGS NF Regular
  • Apple Terminal:打开Terminal → Preferences → Profiles → Text,点击_Font_下的Change,选择MesloLGS NFfamily。
  • Microsoft 终端:打开 Settings (Ctrl+,),搜索fontFace并将每个配置文件的值设置为MesloLGS NF如果您使用任何其他终端单击此处进行配置。

2) 安装

克隆 powerlevel10k 存储库

git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ~/powerlevel10k

在 .zshrc 中获取 powerlevel10k 主题脚本

echo 'source ~/powerlevel10k/powerlevel10k.zsh-theme' >>~/.zshrc

按照提示进行设置,如果您想再次更改提示符,只需运行以下命令:

3) 配置

p10k configure

配置文件存在 ~/.p10k.zsh 中,打开可以更改内部设置

这是左边区域的配置

//注意:context  # user@hostname,用户名和主机名
32 |  # The list of segments shown on the left. Fill it with the most important segments.
33 |  typeset -g POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(
34 |    # =========================[ Line #1 ]=========================
35 |    # os_icon               # os identifier
36 |    dir                     # current directory
37 |    vcs                     # git status
38 |    # =========================[ Line #2 ]=========================
39 |    newline                 # \n
40 |    # prompt_char           # prompt symbol
41 |  )

这是右边区域的配置

47  |  typeset -g POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(
48  |    # =========================[ Line #1 ]=========================
49  |    status                  # exit code of the last command
50  |    command_execution_time  # duration of the last command
51  |    background_jobs         # presence of background jobs
52  |    direnv                  # direnv status (https://direnv.net/)
53  |    asdf                    # asdf version manager (https://github.com/asdf-vm/asdf)
54  |    virtualenv              # python virtual environment (https://docs.python.org/3/library/venv.html)
55  |    anaconda                # conda environment (https://conda.io/)
.   |   .
.   |   .
.   |   .
101 |    todo                    # todo items (https://github.com/todotxt/todo.txt-cli)
102 |    # swap                  # used swap
103 |    time                    # current time
104 |    # =========================[ Line #2 ]=========================
105 |    newline
106 |    # ip                    # ip address and bandwidth usage for a specified network interface
107 |    # public_ip             # public IP address
108 |    # proxy                 # system-wide http/https/ftp proxy
109 |    # battery               # internal battery
110 |    # wifi                  # wifi speed
111 |    # example               # example user-defined segment (see prompt_example function below)
112 |  )

三、Zsh-autosuggestions 和 Zsh-syntax-highlighting

1)Zsh-自动建议

克隆 Zsh-autosuggestions 存储库

git clone https://github.com/zsh-users/zsh-autosuggestions ~/.zsh/zsh-autosuggestions

在 .zshrc 中获取脚本

echo 'source ~/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh'>>~/.zshrc

2)Zsh-syntax-highlighting

克隆 Zsh-syntax-highlighting 存储库

git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ~/.zsh/zsh-syntax-highlighting

在 .zshrc 中获取脚本

echo 'source ~/.zsh/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh'>>~/.zshrc