Windows Terminal 简单美化
                                                            生活随笔
收集整理的這篇文章主要介紹了
                                Windows Terminal 简单美化
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.                        
                                需要用到的軟件/插件
- oh-my-posh
- posh-git
- PSReadLine
安裝 oh-my-posh
oh-my-posh 是 shell 主題引擎,使用 winget 來安裝 oh-my-posh
winget serach oh-my-posh # 找到對應的 id 方便在下一步使用(具體見下圖)
winget install JanDeDobbeleer.OhMyPosh # 等該命令執行完成就安裝好了
安裝字體
由于 oh-my-posh 主題一般都有一些比較特殊的符號,如果安裝后 powershell 提示符出現方框類的字符就需要安裝字體了。
oh-my-posh font install # 如果安裝 oh-my-posh 時是全局安裝則需要管理員權限去執行這條命令
安裝 posh-git
PowerShellGet\Install-Module posh-git -Scope CurrentUser # -Scope CurrentUser 表示當前用戶
安裝/升級 PSReadLine
PowerShellGet\Install-Module posh-git -Scope CurrentUser 
# -Scope CurrentUser 表示當前用戶
# Install-Module 安裝模塊
# Update-Module 升級模塊
安裝之后的效果(灰色部分為之前輸入過的命令,可以按方向鍵的上下進行切換):
這個工具主要做命令提示管理等操作;安裝操作可選的( 這個模塊是自帶的,如果不可用時需要卸載并重新安裝)
配置文件
notepad $profile # 有 vscode 可以使用 code $prifile 來配置
在彈出的窗口中將下面的內容復制進入即可
Import-Module posh-git  # 在當前打開的 PowerShell 終端中引入 posh-git(已安裝,這里只是引入)
Import-Module PSReadLine  # 這個工具主要做命令提示管理等操作,默認集成在 PowerShell 中,不需要安裝
Set-PSReadlineKeyHandler -Key Tab -Function Complete  # 設置 Tab 鍵補全
Set-PSReadLineKeyHandler -Key "Ctrl+d" -Function MenuComplete  # 設置 Ctrl+D 為菜單補全和 Intellisense
Set-PSReadLineKeyHandler -Key "Ctrl+z" -Function Undo  # 設置 Ctrl+Z 為撤銷
Set-PSReadLineKeyHandler -Key UpArrow -Function HistorySearchBackward  # 設置向上鍵為后向搜索歷史記錄
Set-PSReadLineKeyHandler -Key DownArrow -Function HistorySearchForward  # 設置向下鍵為前向搜索歷史記錄
# 啟動時加載 ohMyPosh
# --config 是加載 oh-my-posh 配置的
oh-my-posh init pwsh --config D:\Software\oh-my-posh\conf\pure.omp.json | Invoke-Expression
Import-Module scoop-completion
最后重啟終端就可以看到效果了。
參考/附錄
- Windows 程序包管理器 | Microsoft Learn
- Windows | Oh My Posh
- posh-git/README.md at v0 · dahlbyk/posh-git (github.com)
總結
以上是生活随笔為你收集整理的Windows Terminal 简单美化的全部內容,希望文章能夠幫你解決所遇到的問題。
 
                            
                        - 上一篇: 比亚迪与一汽集团合资投建电池项目
- 下一篇: 怎么样才能生龙凤胎?有什么秘诀能提高生龙
