Windows 終端機看起來很沉悶,所以我讓它看起來很酷

WBOY
發布: 2024-07-17 16:05:45
原創
409 人瀏覽過

不喜歡 Windows 終端機「黑色螢幕上白色文字」的舊外觀?我也不。很高興,你不必堅持下去。以下是您如何更改與終端相關的幾個項目,以及如何完全改變它的外觀和感覺。

內建自訂選項是一個很好的開始

Windows 終端包含許多內建設置,您可以調整以執行即時外觀升級。確保您已從 Microsoft Store 安裝了 Windows 終端應用程式。

The Windows Terminal Looks Dull, so I Made It Look Cool

轉到任務欄中的“搜尋”並輸入“終端”,然後打開頂部結果。

The Windows Terminal Looks Dull, so I Made It Look Cool

在標題列上,按下拉按鈕並轉到「設定」。

The Windows Terminal Looks Dull, so I Made It Look Cool

從現在開始,我們將調整不同的設定來更改 Windows 終端的外觀和感覺。

標題列

讓我們從標題列開始。目前,它具有純黑色,但您可以將其設定為透明。轉到“外觀”,啟用“在選項卡行中使用丙烯酸材料”,然後按一下“儲存”以提交變更。

The Windows Terminal Looks Dull, so I Made It Look Cool

標題列應該變得透明並具有模糊效果。您將看到終端機視窗後面但在模糊玻璃後面的任何內容。

The Windows Terminal Looks Dull, so I Made It Look Cool

更改主題

在「外觀」選單中,您可以從「應用程式主題」下拉式選單中選擇淺色和深色主題。

The Windows Terminal Looks Dull, so I Made It Look Cool

“配色方案”選單包含更多主題,或者您甚至可以創建自己的配色方案。

The Windows Terminal Looks Dull, so I Made It Look Cool

在添加新的配色方案時,您有兩個選擇。

您可以按下「新增」按鈕,嘗試顏色選擇,然後按下「儲存」按鈕將其儲存為新的配色方案。然後,您可以從配色方案清單中選擇該方案。您需要將其設為預設值才能開始使用它。

The Windows Terminal Looks Dull, so I Made It Look Cool The Windows Terminal Looks Dull, so I Made It Look Cool The Windows Terminal Looks Dull, so I Made It Look Cool

另一種選擇是使用 JSON 程式碼定義配色方案並將其新增至終端的 JSON 檔案中。

首先,您需要為您的配色方案建立 JSON 程式碼。但是,您可以在互聯網上找到許多為您量身定制的主題。許多網站(例如 Windows 終端機主題和 TerminalSplash)都會為不同主題提供 JSON 程式碼。搜尋並選擇一個適合您口味的。為了進行展示,我選擇了 TerminalSplash 中的 Solarized Dark Patched 主題。

複製 JSON 程式碼後,開啟終端機的 JSON 檔案。

The Windows Terminal Looks Dull, so I Made It Look Cool

它將在 JSON 檔案的預設文字編輯器中打開,可能是記事本。之後,向下捲動直到找到“方案”部分。您還可以使用搜尋功能更快找到它。

The Windows Terminal Looks Dull, so I Made It Look Cool

找到方案部分後,進一步向下滾動,直到到達最後一個方案(每個方案都用大括號括起來,然後用逗號分隔。)在最後一個方案後面添加一個逗號,然後粘貼您的顏色的JSON 程式碼方案。

The Windows Terminal Looks Dull, so I Made It Look Cool

儲存檔案並退出 JSON 檔案。返回“配色方案”選單,您應該在清單中看到新新增的主題。將其設為預設即可使用它。按下“儲存”按鈕儲存您的變更。若要查看新主題的實際效果,請重新啟動 Windows 終端機。

The Windows Terminal Looks Dull, so I Made It Look Cool

字體

若要變更您在終端機中使用的字體,請前往設定檔下的「預設」。然後,在“其他設定”下,轉到“外觀”。

The Windows Terminal Looks Dull, so I Made It Look Cool

您應該在這裡看到一些與字體相關的選項。您可以選擇字體系列、字體大小和字體粗細。

The Windows Terminal Looks Dull, so I Made It Look Cool

有幾種字體可供選擇。如果您願意,您可以從 Nerd Fonts 下載其他字體,安裝它們並配置它們,以便您可以在系統範圍內使用它們,包括終端。

顏色和背景

當您選擇主題時,它會自動選擇一組顏色。但是,您可以單獨調整顏色。這些設定可讓您使用 RGB 值、HSV 值、顏色代碼和圖形顏色選擇器來選擇顏色。您可以設定前景、背景、遊標和選擇的顏色。

The Windows Terminal Looks Dull, so I Made It Look Cool

如果您不喜歡使用純色作為終端背景,您也可以選擇影像。轉到預設值> “外觀”,然後在“背景圖像”下,提供要用作背景的圖像的路徑。您也可以使用桌面壁紙。選擇影像後,您會注意到更多選項,例如影像拉伸模式、對齊方式和不透明度。

The Windows Terminal Looks Dull, so I Made It Look Cool

確保選擇不太亮的圖像作為背景。否則,您將很難看到文字。另一種選擇是將不透明度降低至 50% 左右。

The Windows Terminal Looks Dull, so I Made It Look Cool

使用 Oh My Posh 美化 Windows 終端機

Oh My Posh 是一個用於 shell 的自訂提示主題引擎,包括 CMD 和 PowerShell。它允許您在終端提示上設定豐富多彩且有意義的主題。

安裝和設定 Oh My Posh

要安裝 Oh My Posh,您首先需要安裝 winget 套件管理器。之後,在 CMD 中執行以下命令來安裝 Oh My Posh:

winget install JanDeDobbeleer.OhMyPosh -s winget
登入後複製
The Windows Terminal Looks Dull, so I Made It Look Cool

安裝完成後,重新啟動終端以重新載入 PATH。要確認安裝,請運行:

oh-my-posh
登入後複製
The Windows Terminal Looks Dull, so I Made It Look Cool

太棒了!已經安裝成功了。現在我們可以使用這個工具自訂我們的終端。

自訂終端

要充分利用 Oh My Posh,您應該安裝 Nerd 字體。這是因為 Oh My Posh 使用了系統上預設安裝的字體不支援的許多圖示和字形。如果您在上一個步驟中沒有安裝字體,現在可以使用 Oh My Posh 來安裝。以管理員身份開啟終端機。然後透過執行以下命令查看可用字體:

oh-my-posh font install
登入後複製

您可以滾動並選擇字體來安裝它。我要安裝“Meslo”。

The Windows Terminal Looks Dull, so I Made It Look Cool

或者,您可以透過將字體名稱新增至前面的指令來安裝字體,如下所示:

oh-my-posh font install meslo
登入後複製

之後,透過在fontface 部分新增字體名稱,在settings.json 檔案中將其設為預設值在設定檔下。儲存文件。

The Windows Terminal Looks Dull, so I Made It Look Cool

現在讓我們嘗試 Oh My Posh 主題。開啟 PowerShell 並執行:

oh-my-posh init pwsh --config "$env:POSH_THEMES_PATHjandedobbeleer.omp.json" | Invoke-Expression
登入後複製
The Windows Terminal Looks Dull, so I Made It Look Cool

That already looks better than what we had.

If you're having rendering problems, or seeing unsupported characters in your theme, in the Terminal, go to Settings > Rendering. Turn on "Use the new text renderer ("AtlasEngine")." Also, make sure you've installed a compatible Nerd Font.

However, if you restart the Terminal, it will be gone. So, let's make it the default shell theme for PowerShell. Open your PowerShell profile in a text editor. To open it in Notepad, run:

notepad $PROFILE
登入後複製
登入後複製

In case you don't already have one, you'll get a prompt to create one. Press "Yes." Then enter the following line in the file:

oh-my-posh init pwsh | Invoke-Expression
登入後複製
The Windows Terminal Looks Dull, so I Made It Look Cool

Save the file and reload the profile with this command:

. $PROFILE
登入後複製
登入後複製

Using the above command may show an error about running scripts. In that case, run Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine as administrator first.

Now, whenever you open PowerShell, you'll see the Oh My Posh custom prompt.

The Windows Terminal Looks Dull, so I Made It Look Cool

There are dozens of themes in Oh My Posh. To get a glance of all of them, run this in PowerShell:

Get-PoshThemes
登入後複製
The Windows Terminal Looks Dull, so I Made It Look Cool

I really like the "atomic" theme, so I'll switch to that. To switch the theme, I'll run:

oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH/atomic.omp.json" | Invoke-Expression
登入後複製
The Windows Terminal Looks Dull, so I Made It Look Cool

If you want to switch to another theme, just replace "atomic" with your theme name in the above script.

If you see an error about Get-PSReadLineKeyHandler, run Install-Module PsReadLine -Force as administrator first.

Once again, to make the change stay permanently, open the PowerShell profile file, remove the line you wrote previously and add the above line.

The Windows Terminal Looks Dull, so I Made It Look Cool

Then reload your profile with this command:

. $PROFILE
登入後複製
登入後複製

You can adjust existing themes by color, segments, and icons. First, you'll need to export the theme as a JSON, YAML, or TOML file. Then you can edit that file to make changes and store it as a custom theme. You can even create your own themes in the same way.

A little icing on the cake would be using custom icons in addition to custom fonts in the Terminal. Terminal-Icons, a PowerShell module, lets you add cool icons for folders, scripts, and other types of files. First, install the module with this command as administrator:

Install-Module -Name Terminal-Icons -Repository PSGallery
登入後複製

Then open your PowerShell profile with the command below:

notepad $PROFILE
登入後複製
登入後複製

Add the following line to the file:

Import-Module -Name Terminal-Icons
登入後複製

Save the file and relaunch PowerShell. Lastly, check out the icons by running ls in PowerShell.

The Windows Terminal Looks Dull, so I Made It Look Cool

Combining everything so far, here's my final result.

The Windows Terminal Looks Dull, so I Made It Look Cool

A Beautiful Windows Terminal at Your Service

By now, you should have a cool looking Terminal on your Windows computer. With some creativity, you can make it more flashy. If you'd like to read more on what you can do with Oh My Posh, check the official documentation.

以上是Windows 終端機看起來很沉悶,所以我讓它看起來很酷的詳細內容。更多資訊請關注PHP中文網其他相關文章!

來源:howtogeek.com
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!