一、安装Windows terminal
Windows应用商店搜索下载Windows terminal
二、安装Powershell 7
打开PowerShell,搜索最新版本
winget search Microsoft.PowerShell
输出:
$ winget search Microsoft.PowerShell
名称 ID 版本 源
---------------------------------------------------------------
PowerShell Microsoft.PowerShell 7.2.6.0 winget
PowerShell Preview Microsoft.PowerShell.Preview 7.3.8.0 winget
通过ID安装对应的PowerShell
# 一般安装这个
winget install --id Microsoft.Powershell --source winget
# 或者安装预览版的Powershell
winget install --id Microsoft.Powershell.Preview --source winget
三、使用Scoop
3.1 安装Scoop
Part from 搭建优雅编程环境
步骤 1:在 PowerShell 中打开远程权限
Set-ExecutionPolicy RemoteSigned -scope CurrentUser;
步骤 2:自定义 Scoop 安装目录
$env:SCOOP='Your_Scoop_Path'
[Environment]::SetEnvironmentVariable('SCOOP', $env:SCOOP, 'User')
如果跳过该步骤, Scoop 将默认把所有用户安装的 App 和 Scoop 本身置于C:\Users\user_name\scoop
步骤 3:下载并安装 Scoop
iwr -useb get.scoop.sh | iex
scoop update
上面无法下载的话,可以采用下方的国内镜像
iwr -useb https://gitee.com/glsnames/scoop-installer/raw/master/bin/install.ps1 | iex
scoop config SCOOP_REPO 'https://gitee.com/glsnames/scoop-installer'
scoop update
3.2 添加Scoop库
- Scoop使用本地socks5代理
function proxyscoop {scoop config proxy 127.0.0.1:10809}
function unproxyscoop {scoop config rm proxy}
注意把
10809
改成自己本地代理的端口
之后就可以使用proxyscoop
命令启用Scoop代理,unproxyscoop
命令取消Scoop代理。
- 查看官方推荐仓库
$ scoop bucket known
main [默认]
extras [墙裂推荐]
versions
nightlies
nirsoft
php
nerd-fonts
nonportable
java
games
jetbrains
- 分别下载git、extras、nerd-fonts等
# 添加额外库
scoop bucket add extras
scoop bucket add nerd-fonts
# 安装git
scoop install git
# scoop插件
scoop install scoop-completion
# 安装FiraCode-NF字体
scoop install FiraCode-NF
# 使用 Linux 命令行
scoop install gow
# 调用管理员权限
scoop install sudo
3.3 Scoop 的管理与配置
# 查看已安装程序
scoop list
# 查看更新
scoop status
# 删除旧版本
scoop cleanup
# 自身诊断
scoop checkup
四、Starship
4.1 安装启用starship
打开powershell,使用 Scoop 安装
scoop install starship
或者使用winget安装
winget install --id Starship.Starship
使用VScode打开配置文件
code $PROFILE
配置文件中添加:
Invoke-Expression (&starship init powershell)
安装oh-my-posh
scoop install oh-my-posh
4.2 Windows terminal配置
打开下拉菜单——设置——左下角齿轮图标,编辑json
配置文件
全选删除,粘贴以下内容
点击查看代码
{
"$help": "https://aka.ms/terminal-documentation",
"$schema": "https://aka.ms/terminal-profiles-schema",
"actions":
[
{
"command":
{
"action": "copy",
"singleLine": false
},
"keys": "ctrl+c"
},
{
"command": "paste",
"keys": "ctrl+v"
},
{
"command": "find",
"keys": "ctrl+shift+f"
},
{
"command":
{
"action": "splitPane",
"split": "auto",
"splitMode": "duplicate"
},
"keys": "alt+shift+d"
}
],
"copyFormatting": "none",
"copyOnSelect": true,
"defaultProfile": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
"profiles":
{
"defaults":
{
"opacity": 40,
"useAcrylic": true
},
"list":
[
{
"backgroundImageOpacity": 0.25,
"closeOnExit": "graceful",
"colorScheme": "Aurora",
"cursorColor": "#FFFFFF",
"cursorShape": "filledBox",
"font":
{
"face": "DejaVuSansMono Nerd Font",
"size": 12
},
"guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
"historySize": 8001,
"name": "Windows PowerShell",
"opacity": 75,
"padding": "0, 0, 0, 0",
"snapOnInput": true,
"startingDirectory": "%USERPROFILE%",
"useAcrylic": true
},
{
"colorScheme": "Afterglow",
"font":
{
"face": "CodeNewRoman Nerd Font"
},
"guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
"hidden": false,
"name": "\u547d\u4ee4\u63d0\u793a\u7b26"
},
{
"colorScheme": "AdventureTime",
"font":
{
"face": "CodeNewRoman Nerd Font"
},
"guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}",
"hidden": false,
"name": "Azure Cloud Shell",
"source": "Windows.Terminal.Azure"
},
{
"colorScheme": "One Half Dark",
"font":
{
"face": "DejaVuSansMono Nerd Font"
},
"guid": "{2ece5bfe-50ed-5f3a-ab87-5cd4baafed2b}",
"hidden": false,
"name": "Git Bash",
"source": "Git"
},
{
"closeOnExit": "graceful",
"colorScheme": "Homebrew",
"commandline": "C:/Program Files/PowerShell/7/pwsh.exe -nologo",
"cursorColor": "#FFFFFF",
"cursorShape": "bar",
"font":
{
"face": "FiraCode Nerd Font",
"size": 11
},
"guid": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
"hidden": false,
"historySize": 9001,
"name": "PowerShell Core 7",
"opacity": 50,
"padding": "5, 5, 20, 25",
"snapOnInput": true,
"source": "Windows.Terminal.PowershellCore",
"startingDirectory": ".",
"useAcrylic": false
}
]
},
"schemes":
[
{
"background": "#1F1D45",
"black": "#050404",
"blue": "#0F4AC6",
"brightBlack": "#4E7CBF",
"brightBlue": "#1997C6",
"brightCyan": "#C8FAF4",
"brightGreen": "#9EFF6E",
"brightPurple": "#9B5953",
"brightRed": "#FC5F5A",
"brightWhite": "#F6F5FB",
"brightYellow": "#EFC11A",
"cursorColor": "#FFFFFF",
"cyan": "#70A598",
"foreground": "#F8DCC0",
"green": "#4AB118",
"name": "AdventureTime",
"purple": "#665993",
"red": "#BD0013",
"selectionBackground": "#FFFFFF",
"white": "#F8DCC0",
"yellow": "#E7741E"
},
{
"background": "#212121",
"black": "#151515",
"blue": "#6C99BB",
"brightBlack": "#505050",
"brightBlue": "#6C99BB",
"brightCyan": "#7DD6CF",
"brightGreen": "#7E8E50",
"brightPurple": "#9F4E85",
"brightRed": "#AC4142",
"brightWhite": "#F5F5F5",
"brightYellow": "#E5B567",
"cursorColor": "#D0D0D0",
"cyan": "#7DD6CF",
"foreground": "#D0D0D0",
"green": "#7E8E50",
"name": "Afterglow",
"purple": "#9F4E85",
"red": "#AC4142",
"selectionBackground": "#303030",
"white": "#D0D0D0",
"yellow": "#E5B567"
},
{
"background": "#23262E",
"black": "#23262E",
"blue": "#0321D7",
"brightBlack": "#4E7CBF",
"brightBlue": "#03D6B8",
"brightCyan": "#03D6B8",
"brightGreen": "#8FD46D",
"brightPurple": "#EE5D43",
"brightRed": "#F92672",
"brightWhite": "#C74DED",
"brightYellow": "#FFE66D",
"cursorColor": "#EE5D43",
"cyan": "#03D6B8",
"foreground": "#FFCA28",
"green": "#8FD46D",
"name": "Aurora",
"purple": "#EE5D43",
"red": "#F0266F",
"selectionBackground": "#292E38",
"white": "#C74DED",
"yellow": "#FFE66D"
},
{
"background": "#1F2430",
"black": "#191E2A",
"blue": "#6DCBFA",
"brightBlack": "#686868",
"brightBlue": "#73D0FF",
"brightCyan": "#95E6CB",
"brightGreen": "#BAE67E",
"brightPurple": "#D4BFFF",
"brightRed": "#F28779",
"brightWhite": "#FFFFFF",
"brightYellow": "#FFD580",
"cursorColor": "#FFCC66",
"cyan": "#90E1C6",
"foreground": "#CBCCC6",
"green": "#A6CC70",
"name": "Ayu Mirage",
"purple": "#CFBAFA",
"red": "#ED8274",
"selectionBackground": "#33415E",
"white": "#C7C7C7",
"yellow": "#FAD07B"
},
{
"background": "#0C0C0C",
"black": "#0C0C0C",
"blue": "#0037DA",
"brightBlack": "#767676",
"brightBlue": "#3B78FF",
"brightCyan": "#61D6D6",
"brightGreen": "#16C60C",
"brightPurple": "#B4009E",
"brightRed": "#E74856",
"brightWhite": "#F2F2F2",
"brightYellow": "#F9F1A5",
"cursorColor": "#FFFFFF",
"cyan": "#3A96DD",
"foreground": "#CCCCCC",
"green": "#13A10E",
"name": "Campbell",
"purple": "#881798",
"red": "#C50F1F",
"selectionBackground": "#FFFFFF",
"white": "#CCCCCC",
"yellow": "#C19C00"
},
{
"background": "#012456",
"black": "#0C0C0C",
"blue": "#0037DA",
"brightBlack": "#767676",
"brightBlue": "#3B78FF",
"brightCyan": "#61D6D6",
"brightGreen": "#16C60C",
"brightPurple": "#B4009E",
"brightRed": "#E74856",
"brightWhite": "#F2F2F2",
"brightYellow": "#F9F1A5",
"cursorColor": "#FFFFFF",
"cyan": "#3A96DD",
"foreground": "#CCCCCC",
"green": "#13A10E",
"name": "Campbell Powershell",
"purple": "#881798",
"red": "#C50F1F",
"selectionBackground": "#FFFFFF",
"white": "#CCCCCC",
"yellow": "#C19C00"
},
{
"background": "#283033",
"black": "#000000",
"blue": "#6666E9",
"brightBlack": "#D8E3F4",
"brightBlue": "#0000FF",
"brightCyan": "#00E5E5",
"brightGreen": "#00D900",
"brightPurple": "#E500E5",
"brightRed": "#E50000",
"brightWhite": "#E5E5E5",
"brightYellow": "#E5E500",
"cursorColor": "#FFFFFF",
"cyan": "#00A6B2",
"foreground": "#C7C7C7",
"green": "#00A600",
"name": "Homebrew",
"purple": "#B200B2",
"red": "#FC5275",
"selectionBackground": "#FFFFFF",
"white": "#BFBFBF",
"yellow": "#999900"
},
{
"background": "#282C34",
"black": "#282C34",
"blue": "#61AFEF",
"brightBlack": "#5A6374",
"brightBlue": "#61AFEF",
"brightCyan": "#56B6C2",
"brightGreen": "#98C379",
"brightPurple": "#C678DD",
"brightRed": "#E06C75",
"brightWhite": "#DCDFE4",
"brightYellow": "#E5C07B",
"cursorColor": "#FFFFFF",
"cyan": "#56B6C2",
"foreground": "#DCDFE4",
"green": "#98C379",
"name": "One Half Dark",
"purple": "#C678DD",
"red": "#E06C75",
"selectionBackground": "#FFFFFF",
"white": "#DCDFE4",
"yellow": "#E5C07B"
},
{
"background": "#FAFAFA",
"black": "#383A42",
"blue": "#0184BC",
"brightBlack": "#4F525D",
"brightBlue": "#61AFEF",
"brightCyan": "#56B5C1",
"brightGreen": "#98C379",
"brightPurple": "#C577DD",
"brightRed": "#DF6C75",
"brightWhite": "#FFFFFF",
"brightYellow": "#E4C07A",
"cursorColor": "#4F525D",
"cyan": "#0997B3",
"foreground": "#383A42",
"green": "#50A14F",
"name": "One Half Light",
"purple": "#A626A4",
"red": "#E45649",
"selectionBackground": "#FFFFFF",
"white": "#FAFAFA",
"yellow": "#C18301"
},
{
"background": "#002B36",
"black": "#002B36",
"blue": "#268BD2",
"brightBlack": "#073642",
"brightBlue": "#839496",
"brightCyan": "#93A1A1",
"brightGreen": "#586E75",
"brightPurple": "#6C71C4",
"brightRed": "#CB4B16",
"brightWhite": "#FDF6E3",
"brightYellow": "#657B83",
"cursorColor": "#FFFFFF",
"cyan": "#2AA198",
"foreground": "#839496",
"green": "#859900",
"name": "Solarized Dark",
"purple": "#D33682",
"red": "#DC322F",
"selectionBackground": "#FFFFFF",
"white": "#EEE8D5",
"yellow": "#B58900"
},
{
"background": "#FDF6E3",
"black": "#002B36",
"blue": "#268BD2",
"brightBlack": "#073642",
"brightBlue": "#839496",
"brightCyan": "#93A1A1",
"brightGreen": "#586E75",
"brightPurple": "#6C71C4",
"brightRed": "#CB4B16",
"brightWhite": "#FDF6E3",
"brightYellow": "#657B83",
"cursorColor": "#002B36",
"cyan": "#2AA198",
"foreground": "#657B83",
"green": "#859900",
"name": "Solarized Light",
"purple": "#D33682",
"red": "#DC322F",
"selectionBackground": "#FFFFFF",
"white": "#EEE8D5",
"yellow": "#B58900"
},
{
"background": "#000000",
"black": "#000000",
"blue": "#3465A4",
"brightBlack": "#555753",
"brightBlue": "#729FCF",
"brightCyan": "#34E2E2",
"brightGreen": "#8AE234",
"brightPurple": "#AD7FA8",
"brightRed": "#EF2929",
"brightWhite": "#EEEEEC",
"brightYellow": "#FCE94F",
"cursorColor": "#FFFFFF",
"cyan": "#06989A",
"foreground": "#D3D7CF",
"green": "#4E9A06",
"name": "Tango Dark",
"purple": "#75507B",
"red": "#CC0000",
"selectionBackground": "#FFFFFF",
"white": "#D3D7CF",
"yellow": "#C4A000"
},
{
"background": "#FFFFFF",
"black": "#000000",
"blue": "#3465A4",
"brightBlack": "#555753",
"brightBlue": "#729FCF",
"brightCyan": "#34E2E2",
"brightGreen": "#8AE234",
"brightPurple": "#AD7FA8",
"brightRed": "#EF2929",
"brightWhite": "#EEEEEC",
"brightYellow": "#FCE94F",
"cursorColor": "#000000",
"cyan": "#06989A",
"foreground": "#555753",
"green": "#4E9A06",
"name": "Tango Light",
"purple": "#75507B",
"red": "#CC0000",
"selectionBackground": "#FFFFFF",
"white": "#D3D7CF",
"yellow": "#C4A000"
},
{
"background": "#300A24",
"black": "#2E3436",
"blue": "#3465A4",
"brightBlack": "#555753",
"brightBlue": "#729FCF",
"brightCyan": "#34E2E2",
"brightGreen": "#8AE234",
"brightPurple": "#AD7FA8",
"brightRed": "#EF2929",
"brightWhite": "#EEEEEC",
"brightYellow": "#FCE94F",
"cursorColor": "#FFFFFF",
"cyan": "#06989A",
"foreground": "#EEEEEC",
"green": "#4E9A06",
"name": "Ubuntu",
"purple": "#75507B",
"red": "#CC0000",
"selectionBackground": "#FFFFFF",
"white": "#D3D7CF",
"yellow": "#C4A000"
},
{
"background": "#000000",
"black": "#000000",
"blue": "#000080",
"brightBlack": "#808080",
"brightBlue": "#0000FF",
"brightCyan": "#00FFFF",
"brightGreen": "#00FF00",
"brightPurple": "#FF00FF",
"brightRed": "#FF0000",
"brightWhite": "#FFFFFF",
"brightYellow": "#FFFF00",
"cursorColor": "#FFFFFF",
"cyan": "#008080",
"foreground": "#C0C0C0",
"green": "#008000",
"name": "Vintage",
"purple": "#800080",
"red": "#800000",
"selectionBackground": "#FFFFFF",
"white": "#C0C0C0",
"yellow": "#808000"
}
]
}
4.3 PSReadLine
- 安装
打开Windows terminal,输入以下命令:
Install-Module PowerShellGet -scope CurrentUser -Force -AllowClobber
Install-Module PSReadLine -scope CurrentUser -Force
- 配置
打开配置文件
code $PROFILE
添加以下配置
Import-Module PSReadLine
Set-PSReadlineKeyHandler -Key Tab -Function Complete
Set-PSReadLineKeyHandler -Key "Ctrl+d" -Function MenuComplete
Set-PSReadLineKeyHandler -Key "Ctrl+z" -Function Undo
Set-PSReadLineKeyHandler -Key UpArrow -Function HistorySearchBackward
Set-PSReadLineKeyHandler -Key DownArrow -Function HistorySearchForward
4.4 整合Scoop
打开Windows terminal,输入以下命令:
Import-Module "$($(Get-Item $(Get-Command scoop).Path).Directory.Parent.FullName)\modules\scoop-completion"
Import-Module "$($(Get-Item $(Get-Command scoop).Path).Directory.Parent.FullName)\modules\scoop-completion" -ErrorAction SilentlyContinue
标签:name,Windows,yellow,terminal,scoop,cyan,FFFFFF,cursorColor
From: https://www.cnblogs.com/leebri/p/16811406.html