用开源工具定制 Mac 终端主题的 4 个步骤
Mac 终端 Zsh

> 
> 用开源工具让你的终端窗口在 Mac 上漂亮起来。
> 
> 
> 


![](/data/attachment/album/202104/22/234534t3t7ntpvdde3v892.jpg "4 different color terminal windows with code")


你是否曾经厌倦了在你的 macOS 电脑上看到同样老式的终端窗口？如果是这样，使用开源的 Oh My Zsh 框架和 Powerlevel10k 主题为你的视图添加一些点缀。


这个基本的逐步教程将让你开始定制你的 macOS 终端。如果你是一个 Linux 用户，请查看 Seth Kenlon 的指南 [为 Zsh 添加主题和插件](https://opensource.com/article/19/9/adding-plugins-zsh) 以获得深入指导。


### 步骤 1：安装 Oh My Zsh


[Oh My Zsh](https://ohmyz.sh/) 是一个开源的、社区驱动的框架，用于管理你的 Z shell （Zsh） 配置。


![Oh My Zsh](/data/attachment/album/202104/22/234543tvoq2aflgf0lvrrg.jpg "Oh My Zsh")


Oh My Zsh 是在 MIT 许可下发布的。使用以下命令安装：



```
$ sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

```

### 步骤 2：安装 Powerlevel10k 字体


![Powerlevel10k](/data/attachment/album/202104/22/234543znszto4qq4kprywy.jpg "Powerlevel10k")


Powerlevel10k 是一个 MIT 许可的 Zsh 主题。在安装 Powerlevel10k 之前，你需要为你的终端安装自定义字体。


到 [Powerlevel10 GitHub](https://github.com/romkatv/powerlevel10k) 页面，在 `README` 中 搜索 “fonts”。安装自定义字体的步骤会根据你的操作系统而有所不同。这只需要简单地点击-下载-安装的系列操作。


![Powerlevel10k fonts](/data/attachment/album/202104/22/234544i1nfupm74f474izi.jpg "Powerlevel10k fonts")


### 步骤 3：安装 Powerlevel10k 主题


接下来，运行以下命令安装 Powerlevel10k：



```
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k

```

完成后，用文本编辑器，比如 [Vim](https://opensource.com/resources/what-vim)，打开 `~/.zshrc` 配置文件，设置行 `ZSH_THEME="powerlevel10k/powerlevel10k`，然后保存文件。


### 步骤 4：完成 Powerlevel10 的设置


打开一个新的终端，你应该看到 Powerlevel10k 配置向导。如果没有，运行 `p10k configure` 来调出配置向导。如果你在步骤 2 中安装了自定义字体，那么图标和符号应该正确显示。将默认字体更改为 `MeslowLG NF`。


![Powerlevel10k configuration](/data/attachment/album/202104/22/234544o83tzqyw8wy3ifif.jpg "Powerlevel10k configuration")


当你完成配置后，你应该会看到一个漂亮的终端。


![Oh My Zsh/Powerlevel10k theme](/data/attachment/album/202104/22/234544uad7cvvmu353e9l6.jpg "Oh My Zsh/Powerlevel10k theme")


就是这些了！你应该可以享受你美丽的新终端了。




---


via: <https://opensource.com/article/21/4/zsh-mac>


作者：[Bryant Son](https://opensource.com/users/brson) 选题：[lujun9972](https://github.com/lujun9972) 译者：[geekpi](https://github.com/geekpi) 校对：[wxy](https://github.com/wxy)


本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译，[Linux中国](https://linux.cn/) 荣誉推出


OK
Do you ever get bored with seeing the same old terminal window on your macOS computer? If so, add some bells and whistles to your view with the open source Oh My Zsh framework and Powerlevel10k theme.


This basic step-by-step walkthrough (including a video tutorial at the end) will get you started customizing your macOS terminal. If you're a Linux user, check out Seth Kenlon's guide to [Adding themes and plugins to Zsh](https://opensource.com/article/19/9/adding-plugins-zsh) for in-depth guidance.

## Step 1: Install Oh My Zsh

[Oh My Zsh](https://ohmyz.sh/) is an open source, community-driven framework for managing your Z shell (Zsh) configuration.

![Oh My Zsh Oh My Zsh](https://opensource.com/sites/default/files/uploads/1_ohmyzsh.jpg)

(Bryant Son, CC BY-SA 4.0)

Oh My Zsh is released under the MIT License. Install it with:

`$ sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"`


## Step 2: Install Powerlevel10k fonts

![Powerlevel10k Powerlevel10k](https://opensource.com/sites/default/files/uploads/2_powerlevel10k.jpg)

(Bryant Son, CC BY-SA 4.0)

Powerlevel10k is an MIT-Licensed Zsh theme. Before installing Powerlevel10k, you will want to install custom fonts for your terminal.

Go to the [Powerlevel10 GitHub](https://github.com/romkatv/powerlevel10k) page, and search for "fonts" in the README. The steps for installing the custom fonts will vary depending on your operating system; the video at the bottom of this page explains how to do it on macOS. It should be just a simple click–download–install series of operations.

![Powerlevel10k fonts Powerlevel10k fonts](https://opensource.com/sites/default/files/uploads/3_downloadfonts.jpg)

(Bryant Son, CC BY-SA 4.0)

## Step 3: Install the Powerlevel10k theme

Next, install Powerlevel10k by running:

`git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k`


After you finish, open a `~/.zshrc`

configuration file with a text editor, such as [Vim](https://opensource.com/resources/what-vim), set the line `ZSH_THEME="powerlevel10k/powerlevel10k`

, then save the file.

## Step 4: Finalize your Powerlevel10k setup

Open a new terminal, and you should see the Powerlevel10k configuration wizard. If not, run `p10k configure`

to bring up the configuration wizard. If you installed the custom fonts in Step 2, the icons and symbols should display correctly. Change the default font to **MeslowLG NF** (see the video below for instructions).

![Powerlevel10k configuration Powerlevel10k configuration](https://opensource.com/sites/default/files/uploads/4_p10kconfiguration.jpg)

(Bryant Son, CC BY-SA 4.0)

Once you complete the configuration, you should see a beautiful terminal.

![Oh My Zsh/Powerlevel10k theme Oh My Zsh/Powerlevel10k theme](https://opensource.com/sites/default/files/uploads/5_finalresult.jpg)

(Bryant Son, CC BY-SA 4.0)

If you want to see an interactive tutorial, please check out this video:


That's it! You should be ready to enjoy your beautiful new terminal. Be sure to check out other Opensource.com articles for more tips and articles on using the shell, Linux administration, and more.

## Comments are closed.