W

Windows 终端主题美化你的 Windows 终端🦄

2025-05-27

Windows 终端主题美化你的 Windows 终端🦄

编辑 - ⚠️ 由于 oh-my-posh 版本较新,且与 V2 版本相比有显著变化,本文已过时。请注意,本文在 oh-my-posh V2 版本上仍然可以完美运行。


Windows 终端是一个现代、快速、高效、强大且高效的终端应用程序,适用于命令提示符、PowerShell 和 WSL 等命令行工具和 shell 的用户。


终端

让我们从Windows 终端安装开始 -

  • 从 Microsoft Store 安装 Windows 终端。这样,当我们发布具有自动升级功能的最新版本时,您就可以始终使用最新版本。
    • 替代方法(通过 Chocolately)-choco install microsoft-windows-terminal

下一步是修改 Windows 终端设置。

启动已安装的 Windows 终端,并打开其设置,这将在您的默认编辑器中打开 settings.json。

  1. 在配置文件列表下将 powershell 配置文件更新为 -


 {
       // Make changes here to the powershell.exe profile.
       "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
       "name": "Linnea",
       "commandline": "powershell.exe -NoLogo -NoExit",
       "hidden": false,
       "colorScheme": "Blue Matrix",
       "fontFace": "Cascadia Code PL",
       "fontSize": 10,
       "icon": "xxxxxxxxxxxxxxxxxxxxxx",
       "backgroundImage": "xxxxxxxxxxxxxxxxxxx",
       "backgroundImageOpacity": 0.2,
       "acrylicOpacity": 0.8,
       "useAcrylic": true,
       "startingDirectory": "Q:\\Development"
 },


Enter fullscreen mode Exit fullscreen mode

属性 -名称-[显示为顶部栏中的标题]
acrylicOpacity -[只是窗口的不透明度]
useAcrylic -[要使用acrylicOpacity,它必须为真]
图标-[显示为窗口的图标]

(注 1- 确保根据您的个人喜好更新图标和背景图像)
(注 2- 确保您的 defaultProfile 具有您的 powershell 的 guid)

  1. 下一步是更新我们的方案列表 -

    
    
     "schemes": [
        {
            "name": "Blue Matrix",
            "black": "#101116",
            "red": "#ff5680",
            "green": "#00ff9c",
            "yellow": "#fffc58",
            "blue": "#00b0ff",
            "purple": "#d57bff",
            "cyan": "#76c1ff",
            "white": "#c7c7c7",
            "brightBlack": "#686868",
            "brightRed": "#ff6e67",
            "brightGreen": "#5ffa68",
            "brightYellow": "#fffc67",
            "brightBlue": "#6871ff",
            "brightPurple": "#d682ec",
            "brightCyan": "#60fdff",
            "brightWhite": "#ffffff",
            "background": "#1d2342",
            "foreground": "#b8ffe1"
        }
    ],
    
More themes at - [atomcorp.github.io/themes/](https://atomcorp.github.io/themes/)

That's pretty much for the windows Terminal Settings , lets move to add some cool plugins 🔥.

---

### PowerLine Setup ⚡
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/73e98cxinv28jywdxrhb.png)

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/8uejzmvkxrwkxevxohk4.png)

Edit - ⚠️ With the newer version of oh-my-posh, and significant changes from V2. this article needs update. Note that this will still work perfectly fine with V2 of oh-my-posh.

 Prerequisites - 
 - Install [Cascadia code PL](https://github.com/microsoft/cascadia-code/releases) font. (Otherwise you might some gibberish on your terminal )
 - [Git](https://git-scm.com/downloads) for windows
 - Install Posh-git and Oh-my-posh  ( use powershell )
Enter fullscreen mode Exit fullscreen mode

安装模块 posh-git -Scope CurrentUser
安装模块 oh-my-posh -Scope CurrentUser

---

####  Customize your PowerShell prompt 🔨
 - Open your PowerShell profile with `notepad $PROFILE` or the text editor of your choice. This is not your Windows Terminal profile. Your PowerShell profile is a script that runs every time PowerShell starts.
 -  If your powershell doesn't already have a profile, create one -> 
Enter fullscreen mode Exit fullscreen mode
if (!(Test-Path -Path $PROFILE)) { New-Item -ItemType File -Path ROFILE -Force }
Enter fullscreen mode Exit fullscreen mode
- Now go ahead and add the following code to your powershell profile -
Enter fullscreen mode Exit fullscreen mode

导入模块 posh-git
导入模块 oh-my-posh
设置主题悖论

More themes at - [ oh-my-posh themes](https://github.com/JanDeDobbeleer/oh-my-posh#themes)

( ⚠️  if your powershell gives module not found error ) add the following code with default module location, to the top of your Powershell Profile.
Enter fullscreen mode Exit fullscreen mode

$env:PSModulePath = $env:PSModulePath +“$([System.IO.Path] :: PathSeparator)C:\ Users \ xxxx \ Documents \ WindowsPowerShell \ Modules”

Still facing error - Visit [https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_profiles?view=powershell-7](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_profiles?view=powershell-7)


---
### Modifying Oh-my-posh theme ( 🦄🔥🚀 Emojis )

![Emojis](https://dev-to-uploads.s3.amazonaws.com/i/eqttvii2l25877p2vytv.png)

---
Remember we set our default oh-my-posh theme to paradox, lets head over to customize it.

- Navigate to your PSmodules directory, then into oh-my-posh themes directory 
    - `Documents\WindowsPowerShell\Modules\oh-my-posh\2.0.412\Themes`

- Open Paradox file, scroll down to the bottom and update following lines -

Enter fullscreen mode Exit fullscreen mode

$sl.PromptSymbols.StartSymbol = [char]::ConvertFromUtf32(0x01F984) + [char]::ConvertFromUtf32(0x0001F525) + ' '
$sl.PromptSymbols.PromptIndicator = [char]::ConvertFromUtf32(0x01F680) +[char]::ConvertFromUtf32(0x276F)

*(This lines will add cool emojis just before your StartSymbol & PromptIndicator)*

---

### Adding custom banner to your Powershell 🏳️‍🌈

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/uwpi5z246kgy9ubu9i4a.png)
This is quite tedious task if you want to add complex images in the banner.
( There is easier way [Neofetch for windows](https://github.com/dylanaraps/neofetch), but it comes with its own lag overhead whenever you open your windows terminal )

- *Tedious but way less overhead* Method
    -  Change your powershell file to add your custom ascii art. 
    -  In my case, I changed my Profile Image to Ascii Art via [https://www.topster.net/ascii-generator/](https://www.topster.net/ascii-generator/).
    - Next problem is color support, by default powershell doesn't allow you to write multipler colored text on a single line.
    -  ( You could proceed without this ) If want the above function install Write color module.
    `Install-Module -Name PSWriteColor`
    - Now just below your $psenvmodule path add the following lines to display your customized banner .
Enter fullscreen mode Exit fullscreen mode

写入颜色-文本“ /@ ”-颜色青色
写入颜色-文本“ @(","@ ”-颜色蓝色,青色
写入颜色-文本“ @@/"," @* ”-颜色蓝色,青色
写入颜色-文本“ @#/"," @@* ”-颜色蓝色,青色
写入颜色-文本“ @@(/"," @@,, ”-颜色蓝色,青色
写入颜色-文本“ @%(/ @@","@@@@@@","@@@@ ”-颜色蓝色,深青色,青色
写入颜色-文本“ @@#","#"," ”-颜色蓝色,深青色,青色
写入颜色-文本“ @@##","#(((/","/// "," ,,,,,@ ”-颜色蓝色,深蓝色,深青色,青色
写入颜色-文本“ @@%%#","##(((/","///
"," ****,,,,,,@ ”-颜色蓝色,深蓝色,深青色、青色
写入颜色-文本“@@@@@W”、“@@@@@@”、“@@@@@@@”、“@@@@@@@@@@@”-颜色蓝色、深蓝色、深青色、青色
写入颜色-文本“”


*(Note - the number of colors you can choose from is somewhat limited: Black, DarkBlue, DarkGreen, DarkCyan, DarkRed, DarkMagenta, DarkYellow, Gray, DarkGray, Blue, Green, Cyan, Red, Magenta, Yellow, and White )*

Edit 1. - Your Powershell Profile should look like this - [ pastebin.com/JAX3Ce23](pastebin.com/JAX3Ce23)

Edit 2. - Background Image source - [facets.la](facets.la)

Edit 3. - With the new version of oh-my-posh, few commands (ex- set-theme ) have been depreciated. I'm planning to update the article with the specifics, till then use their documentation for updated syntax - [Repo Link](https://github.com/JanDeDobbeleer/oh-my-posh)


----

## Credits

- [Windows Terminal Community ❤](https://github.com/microsoft/terminal) 
- [https://github.com/JanDeDobbeleer/oh-my-posh](https://github.com/JanDeDobbeleer/oh-my-posh)
- [https://github.com/dahlbyk/posh-git](https://github.com/dahlbyk/posh-git)
- [https://github.com/EvotecIT/PSWriteColor](https://github.com/EvotecIT/PSWriteColor)
- [https://github.com/atomcorp/themes](https://github.com/atomcorp/themes)
Enter fullscreen mode Exit fullscreen mode
文章来源:https://dev.to/anupa/beautify-your-windows-terminal-1la8
PREV
排名前 5 的 Tailwind 组件库
NEXT
Git 命令速查表