💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
[TOC] # Windows Terminal 加 powershell7 美化命令行 # 安装字体 ``` scoop install -g nerd-fonts/Cascadia-Code ``` # posh-git 与 oh-my-posh ~~~powershell > Install-Module posh-git -Scope CurrentUser > Install-Module oh-my-posh -Scope CurrentUser > Set-PoshPrompt -Theme Powerlevel10k-Lean # angoster、JanDeDobbeleer # > Set-Theme Powerlevel10k-Lean # angoster ~~~ # posh-git 可以为 PowerShell 提供 git 命令补全。 oh-my-posh 可以美化 prompt,提供各种主题。直接把两个一起安上: ## oh-my-posh oh-my-posh提供了 10 款 漂亮 的主题供我们选择。 ``` `Agnoster`,`Avit`,`Darkblood`,`Fish`,`Honukai`,`Paradox`,`PowerLine`,`robbyrussell`,`Sorin`,`tehrob` ``` # [PSReadLine](https://github.com/PowerShell/PSReadLine) 命令行提示记录 PSReadLine 是 PowerShell 的官方模块,为 PowerShell 提供了缺失的交互特性。例如像 zsh/fish 那样的交互式的补全、语法高亮、emacs按键模式等等。有了 PSReadLIne 之后的 PowerShell 才终于像点样了。 安装([详见官方项目README](https://github.com/PowerShell/PSReadLine)): ```powershell > Install-Module -Name PSReadLine -AllowPrerelease -Force # PSReadLine ``` 安装之后,PSReadLine 的一些特性并不会自动启用,可以在 PowerShell 的 profile 配置文件里自己按需配置。但是自己从头搞毕竟很烦,直接白嫖官方提供的[配置样例](https://github.com/PowerShell/PSReadLine/blob/master/PSReadLine/SamplePSReadLineProfile.ps1)就可以,已经非常好用了。 # [Starship](https://starship.rs/zh-CN/guide/) 美化显示样式 Starship 是一个用 Rust 编写的开源项目,它可以帮助你建立一个精简、快速、可定制的 shell 提示符;配置各种语言工程**prompt**的**icon**,文档有完整的例子: ``` > scoop install starship ``` ## 配置`starship` 创建这个文件夹并创建`startship.toml` 如果有这个`.config`这个文件夹,直接 ``` > touch ~/.config/starship.toml > notepad.exe ~/.config/starship.toml ``` `starship.toml`输入如下内容: ``` [character] symbol = "➜" [aws] symbol = " " [battery] full_symbol = "" charging_symbol = "" discharging_symbol = "" [conda] symbol = " " [docker] symbol = " " [elixir] symbol = " " [elm] symbol = " " [git_branch] symbol = " " [golang] symbol = " " [haskell] symbol = " " [hg_branch] symbol = " " [java] symbol = " " [julia] symbol = " " [memory_usage] symbol = " " [nix_shell] symbol = " " [nodejs] # symbol = " " symbol=" " [package] symbol = " " [php] symbol = " " [python] symbol = " " [ruby] symbol = " " [rust] symbol = " " ``` 具体配置看[官网](https://gitee.com/mirrors/starship),如果出现的小方框或者乱码是字体缺失,那么需要安装一种 [Nerd 字体](https://www.nerdfonts.com/) 并在您的终端启用! ## 配置 Nerd Font 字体 1. 下载`FiraCode Nerd Font`字体 或其他自己喜欢的字体 打开 [nerdfonts](https://www.nerdfonts.com/font-downloads) 网站,滑到找到`FiraCode Nerd Font`下载解压,全选&右键安装 > 个人使用 [i-tu/Hasklig](https://hub.fastgit.org/i-tu/Hasklig/releases) 字体 1. 在`windows terminal`中配置字体: ```json ..... // powershell 7 { "guid": "{574e775e-4f2a-5b96-ac1e-a2962a402336}", "hidden": false, "name": "PowerShell", "commandline": "C:/Program Files/PowerShell/7-preview/pwsh.exe -nologo", "fontSize": 12, // 字体配置 "fontFace": "FiraCode Nerd Font", "historySize": 9001, "padding": "5, 5, 20, 25", "snapOnInput": true, "colorScheme": "Andromeda", "source": "Windows.Terminal.PowershellCore" } ..... ``` # [colortool](https://github.com/microsoft/terminal/releases/tag/1708.14008) 颜色配置 主要是配置字体和配色方案。配色方案可以使用 `colortool`,或者在 [iTerm2-Color-Schemes](https://hub.fastgit.org/mbadolato/iTerm2-Color-Schemes) 这个项目中挑选。个人比较喜欢 Gruvbox Dark 配色。 ``` > scoop install colortool ``` ## 配置`colortool` ```powershell > colortool -s # 查看配色方案 > colortool OneHalfDark.itermcolors # colortools 后面跟主题名字就行 ``` 在 Windows Terminal 配置文件中加入 Gruvbox Dark 配色方案: ~~~json "schemes": [ { "name": "Xee Gruvbox Dark", "black": "#1e1e1e", "red": "#be0f17", "green": "#868715", "yellow": "#cc881a", "blue": "#377375", "purple": "#a04b73", "cyan": "#578e57", "white": "#978771", "brightBlack": "#7f7061", "brightRed": "#f73028", "brightGreen": "#aab01e", "brightYellow": "#f7b125", "brightBlue": "#719586", "brightPurple": "#c77089", "brightCyan": "#7db669", "brightWhite": "#e6d4a3", "background": "#1e1e1e", "foreground": "#e6d4a3" } ] ~~~ ## 其他主题工具 [atomcorp/themes: Themes for Windows Terminal](https://github.com/atomcorp/themes) 直接由主题网站浏览顺眼的配色,再一键复制并贴入Windows Terminal的设定档,超级简单! * 配色主题展示:[iTerm2 Color Schemes](https://github.com/mbadolato/iTerm2-Color-Schemes/tree/master/windowsterminal) # 参考 > [Windows Terminal 终极美化](https://www.chuchur.com/article/windows-terminal-beautify)