2024/04/10

Windows PowerShell Theme

無意間看到了這個影片How to set up PowerShell prompt with Oh My Posh on Windows 11,沒想到 PowerShell 也可以搞得這麼漂亮,於是參照裡面的設定,幫自己的 PowerShell 做了喜歡的畫面改動。

  1. 安裝 Scoop
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
Invoke-RestMethod -Uri https://get.scoop.sh | Invoke-Expression
  1. 安裝 Nerd Fonts
scoop bucket add nerd-fonts
scoop install Hack-NF


安裝 Nerd Fonts 後,設定 PowerShell 的字體為 Hack Nerd Font,字型大小 11,透明度 85%。

  1. 安裝 Terminal Icons
scoop bucket add extras
scoop install terminal-icons
  1. 安裝 Oh My Posh
scoop install https://github.com/JanDeDobbeleer/oh-my-posh/releases/latest/download/oh-my-posh.json
  1. 安裝 fzf
scoop install fzf
Install-Module -Name PSFzf
  1. 安裝 ZLocation
Install-Module -Name ZLocation -Force
  1. 配置個人環境變數
nvim $PROFILE.CurrentUserAllHosts

Config 內容

Import-Module -Name Terminal-Icons
Import-Module -Name ZLocation

oh-my-posh init pwsh --config '~/AppData/Local/Programs/oh-my-posh/themes/remk.omp.json' | Invoke-Expression

Function Get-LongListingll {
    ~/scoop/shims/ls.exe -l @args
}

Set-Alias ll Get-LongListing
Set-Alias ls ~/scoop/shims/ls.exe

Set-PsFzfOption -PSReadlineChordProvider 'Ctrl+t' -PSReadlineChordReverseHistory 'Ctrl+r's ~/scoop/shims/ls.exe

我選擇了 remk 這個 theme,安裝了套件 busybox 讓他更像 Linux,也同時安裝了 versions

Final Theme
於是我就得到了美美的 terminal。

reference