# PowerShell美化


&gt; Starship: 轻量、迅速、可无限定制的高颜值终端！
&gt; - 兼容性优先:Starship 可以在各种常见的操作系统和常见的 shell 上运行。 尝试着在各种地方使用它吧！
&gt; - 使用 Rust 编写:具有 Rust 独树一帜的速度与安全性，使你的提示符尽可能的快速可靠。
&gt; - 可自定义:每个小细节都可以按您喜欢的自定义，不论是最小化以求速度，还是最大化以获得最完善的功能。
&lt;!--more--&gt;

## 前置要求 下载字体并安装

- 安装一个 [Nerd Font (opens new window)](https://www.nerdfonts.com/)的字体，并在终端启用（例如，可以尝试使用 [Fira Code Nerd Font (opens new window)](https://www.nerdfonts.com/font-downloads)字体）。

选择自己喜欢的字体，解压后全选右键安装。

这里推荐[CascadiaCode](https://github.com/ryanoasis/nerd-fonts/releases/download/v2.2.2/CascadiaCode.zip)这款字体，有连写效果非常好看！

配置如下图：

![image-20230102181232997](https://img.nil.lc/img/202301021812048.png)

![image-20230102181320835](https://img.nil.lc/img/202301021813885.png)

## 第一步 安装Starship

- 使用命令行安装

```powershell
winget install --id Starship.Starship
```

- 安装包安装

  [starship](https://github.com/starship/starship/releases/latest)

## 第二步 设置你的终端以使用 Starship

通过`$PROFILE`来确定你配置文件所在路径，如果你的电脑上没有该路径就创建。

```powershell
❯ $PROFILE
C:\Users\hiifong\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
```

在配置文件末尾添加`Invoke-Expression (&amp;starship init powershell)`，可以使用记事本快速打开配置文件，命令为：`notepad $PROFILE`。

## 第三步 配置Starship

配置这里我选择社区的[Bracketed Segments Preset](https://starship.rs/presets/toml/bracketed-segments.toml)配置。

- ```sh
  starship preset bracketed-segments &gt; ~/.config/starship.toml
  ```

  这个方法可能会提示`[ERROR] - (starship::config): Unable to read config file content: stream did not contain valid UTF-8`，这时候用`vscode`打开`starship.toml`配置文件，把编码修改为`UTF-8`就好了。

​	OR

- 下载解压后，把`bracketed-segments.toml`重命名为`starship.toml`并复制到`C:\Users\你的用户名\.config`目录下，如果提示已存在就选择替换。

至此`starship`以配置完成。



**效果图：**

![image-20230102181724510](https://img.nil.lc/img/202301021817561.png)

![image-20230102181753398](https://img.nil.lc/img/202301021817448.png)

**Enjoy it！**


---

> 作者: hiifong  
> URL: https://f.style/beautify/  

