安裝windows terminal
微軟商店安裝,搜索terminal,安裝即可
打開方式
①在文檔框輸入 wt
②註冊表 regedit
-
計算機\HKEY_CLASSES_ROOT\Directory\Background\shell
-
右鍵 > 新建 > 項,名稱填寫 “在此處打開 Terminal”
-
在新建的 “在此處打開 Terminal” 上右鍵 > 新建 > 項,名稱填寫“command”,
-
參數如下,記得替換xxx
cmd /c set CURRENT_PATH="%V" & start C:\Users\xxx\AppData\Local\Microsoft\WindowsApps\wt.exe
-
在任意位置右鍵
效果
安裝字體
可以到微軟商店安裝,搜索更紗黑體,不然oh-my-posh設置的主題會亂碼
安裝模塊
# 安裝posh-git和oh-my-posh
Install-Module posh-git -Scope CurrentUser
Install-Module oh-my-posh -Scope CurrentUser
# 啓用默認設置
Set-Prompt
# 選中主題
Set-Theme Paradox
# 使用記事本打開PS配置文件(如無則創建該文件)
if (!(Test-Path -Path $PROFILE )) { New-Item -Type File -Path $PROFILE -Force }
# 編輯文件
notepad $PROFILE
# 編輯內容
Import-Module posh-git
Import-Module oh-my-posh
Set-Theme Paradox
配置文件路徑如下,可以設置vscode爲json編輯器
C:\Users\26825\AppData\Local\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json
terminal配置大致如下
{
//窗口大小
"initialCols": 80,
"initialRows": 20,
//右鍵複製
"copyOnSelect": true,
"profiles": {
"defaults": {
...
},
"list": [{
...
}]
},
"schemes": [{
...
}],
}
defaults配置
{
"acrylicOpacity" : 0.90, //亞克力背景透明度(需啓用useAcrylic)
// "background" : "#012456", //背景顏色,PS默認爲藍色
"closeOnExit" : true, //關閉窗口的時候退出所有掛載的程序
"colorScheme" : "Dracula", //配色方案(Dracula需導入)
"commandline" : "powershell.exe", //此處終端打開PS
"cursorColor" : "#FFFFFF", //光標顏色
"cursorShape" : "bar", //光標形狀(默認爲bar,即條狀)
"fontFace" : "等距更紗黑體 SC", //所用字體
"fontSize" : 12, //字體大小
"name": "Windows PowerShell", //在下拉菜單裏顯示的名稱
"tabTitle" : "Windows PowerShell", //在選項卡上顯示的名稱
"padding" : "0, 0, 0, 0", //內容的邊框距,默認填充全部空間
"snapOnInput" : true, //輸入的時候自動滾動到輸入位置
"startingDirectory" : ".", //初始工作目錄,默認爲用戶目錄
"useAcrylic" : true //使用亞克力效果
}
schemes配置
"schemes": [
{
"background" : "#282A36",
"black" : "#21222C",
"blue" : "#BD93F9",
"brightBlack" : "#6272A4",
"brightBlue" : "#D6ACFF",
"brightCyan" : "#A4FFFF",
"brightGreen" : "#69FF94",
"brightPurple" : "#FF92DF",
"brightRed" : "#FF6E6E",
"brightWhite" : "#FFFFFF",
"brightYellow" : "#FFFFA5",
"cyan" : "#8BE9FD",
"foreground" : "#F8F8F2",
"green" : "#50FA7B",
"name" : "Dracula",
"purple" : "#FF79C6",
"red" : "#FF5555",
"white" : "#F8F8F2",
"yellow" : "#F1FA8C"
}
],
安裝gsudo管理員模塊
用法與sudo一樣
PowerShell -Command "Set-ExecutionPolicy RemoteSigned -scope Process; iwr -useb https://raw.githubusercontent.com/gerardog/gsudo/master/installgsudo.ps1 | iex"
並配置如下內容:
"list": [
{
"guid": "{41dd7a51-f0e1-4420-a2ec-1a7130b7e950}",
"name": "Windows PowerShell Elevated",
"commandline": "gsudo.exe powershell.exe",
"hidden": false,
"colorScheme": "Solarized Dark",
"fontFace": "Fira Code",
"icon" : "https://i.imgur.com/Giuj3FT.png"
},
//...
]
最終效果
查看模塊
①確定已安裝 PowerShell 庫中的哪些模塊,請運行
Get-InstalledModule
②同樣,若要確定已安裝 PowerShell 庫中的哪些腳本,請運行
Get-InstalledScript
③獲取更高版本
Update-Module
④查看環境變量包含bin目錄
(type env:path) -split ';' | sls bin