共计 6018 个字符,预计需要花费 16 分钟才能阅读完成。
强化 win10 下的命令行 – 颜值和实用并存
0x1 装置 Windows Terminal
在 Microsoft Store 中下载 Windows Terminal
留神零碎要求
<img src=”https://image.yoouu.cn/2020/win10-terminal/win10-terminal.png” alt=”win10-terminal” style=”zoom:50%;” />
0x2 装置 PowerShell core
下载地址:https://github.com/PowerShell/PowerShell/releases
win10 抉择 PowerShell-7.1.0-preview.7-win-x64.msi
这种装置即可
<img src=”https://image.yoouu.cn/2020/win10-terminal/poweishell-core.png” alt=”poweishell-core” style=”zoom:50%;” />
0x3 装置字体(可选)
FiraCode – 连字符字体
<img src=”https://image.yoouu.cn/sunseekerx/resource/FiraCode.svg” alt=”FiraCode” style=”zoom: 33%;” />
JetBrainsMono – IDEA 系字体,集体用的这个
0x4 装置 PowerShell 模块
0x1 输出以下命令
通过在 PowerShell 中执行上面的命令装置, 以超级管理员运行 PowerShell
右键桌面空白的中央抉择 PowerShell > Open Here as Administrator
CurrentUser 是仅为以后用户装置模块
!如果呈现 PowerShell 因为在此零碎上禁止运行脚本…
输出以下命令
# 更改执行策略 set-ExecutionPolicy RemoteSigned # 查看执行策略 get-ExecutionPolicy
Install-Module posh-git -Scope CurrentUser
Install-Module oh-my-posh -Scope CurrentUser
0x2 如果下载慢的话能够应用命令行代理
# 设置代理(填写你本地的端口)netsh winhttp set proxy 127.0.0.1:1080
# 勾销代理
netsh winhttp reset proxy
# 查看代理
netsh winhttp show proxy
0x5 配置 PowerShell
0x1 输出:
$PROFILE
# C:\Users\SunSeekerX\Documents\PowerShell\Microsoft.PowerShell_profile.ps1
0x2 持续输出:
if (!(Test-Path -Path $PROFILE)) {New-Item -Type File -Path $PROFILE -Force}
notepad $PROFILE
0x3 在关上的文件中增加:Set-Theme Paradox 是设置默认主题
该文件是每次启动 PowerShell 执行的文件,加载两个模块和设置主题。
其余可选主题有
Agnoster、Avit、Darkblood、Fish、Honukai、Paradox、Sorin、tehrob
Import-Module posh-git
Import-Module oh-my-posh
Set-Theme Paradox
0x4 保留后敞开记事本, 在终端中输出以下命令失效(这里不要照抄 上面执行的 是 上文中 $PROFILE 的值)
C:\Users\SunSeekerX\Documents\PowerShell\Microsoft.PowerShell_profile.ps1
0x5 切换主题
Set-Theme 主题名字
0x6 配置 Windows Terminal
官网具体配置阐明
配置主题配色
0x1 关上配置文件 setting.json
<img src=”https://image.yoouu.cn/2020/win10-terminal/pwsh.png” alt=”pwsh” style=”zoom: 50%;” />
0x2 参考以下配置
可自行批改,肯定要合乎 json 的内容格局,不然会报错,还有就是图片的的门路要与己零碎对应
改的比拟多的就是 profiles > defaults
和 schemes
,前者是启动的配置,后者是主题配色。
上面的配置不要全副复制,能够选择性的更改你的配置!
{
"$schema": "https://aka.ms/terminal-profiles-schema",
"defaultProfile": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
"copyOnSelect": false,
"copyFormatting": false,
"profiles": {
"defaults": {
"fontFace": "JetBrains Mono", // oh-my-posh 主题起因,应用其余的字体可能会呈现乱码
// "backgroundImage": "C:\\bash-bg.jpg", // 背景图片地址
// "backgroundImageOpacity": 0.5, // 透明度
"colorScheme": "ayu", // 色彩计划
"acrylicOpacity": 0.7,
"useAcrylic": true
},
"list": [
{
// Make changes here to the powershell.exe profile.
"guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
"name": "Windows PowerShell",
"commandline": "powershell.exe",
"hidden": false,
"startingDirectory": null
},
{
// Make changes here to the cmd.exe profile.
"guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
"name": "命令提示符",
"commandline": "cmd.exe",
"hidden": false,
"startingDirectory": null
},
{"guid": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
"hidden": false,
"name": "PowerShell",
"source": "Windows.Terminal.PowershellCore",
"startingDirectory": null
},
{"guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}",
"hidden": false,
"name": "Azure Cloud Shell",
"source": "Windows.Terminal.Azure",
"startingDirectory": null
}
]
},
// 配色计划
"schemes": [
{
"name": "Andromeda",
"black": "#000000",
"red": "#cd3131",
"green": "#05bc79",
"yellow": "#09da0f",
"blue": "#2472c8",
"purple": "#bc3fbc",
"cyan": "#0fa8cd",
"white": "#e5e5e5",
"brightBlack": "#666666",
"brightRed": "#cd3131",
"brightGreen": "#05bc79",
"brightYellow": "#09da0f",
"brightBlue": "#2472c8",
"brightPurple": "#bc3fbc",
"brightCyan": "#0fa8cd",
"brightWhite": "#e5e5e5",
"background": "#262a33",
"foreground": "#e5e5e5"
},
{
"name": "Campbell",
"foreground": "#F2F2F2",
"background": "#0C0C0C",
"colors": [
"#0C0C0C",
"#C50F1F",
"#13A10E",
"#C19C00",
"#0037DA",
"#881798",
"#3A96DD",
"#CCCCCC",
"#767676",
"#E74856",
"#16C60C",
"#F9F1A5",
"#3B78FF",
"#B4009E",
"#61D6D6",
"#F2F2F2"
]
},
{
"name": "Solarized Dark",
"foreground": "#FDF6E3",
"background": "#073642",
"colors": [
"#073642",
"#D30102",
"#859900",
"#B58900",
"#268BD2",
"#D33682",
"#2AA198",
"#EEE8D5",
"#002B36",
"#CB4B16",
"#586E75",
"#657B83",
"#839496",
"#6C71C4",
"#93A1A1",
"#FDF6E3"
]
},
{
"name": "ayu",
"black": "#000000",
"red": "#ff3333",
"green": "#b8cc52",
"yellow": "#e7c547",
"blue": "#36a3d9",
"purple": "#f07178",
"cyan": "#95e6cb",
"white": "#ffffff",
"brightBlack": "#323232",
"brightRed": "#ff6565",
"brightGreen": "#eafe84",
"brightYellow": "#fff779",
"brightBlue": "#68d5ff",
"brightPurple": "#ffa3aa",
"brightCyan": "#c7fffd",
"brightWhite": "#ffffff",
"background": "#0f1419",
"foreground": "#e6e1cf"
}
],
"keybindings": [
{
"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"
}
]
}
0x3 官网更多配色
https://docs.microsoft.com/zh-cn/windows/terminal/customize-settings/color-schemes
增加 Windows Terminal 到右键
<img src=”https://image.yoouu.cn/2020/win10-terminal/right-menu.png” alt=”right-menu” style=”zoom:50%;” />
0x1 下载图标
下载地址:icon,放到 C:\Users\[user_name]\AppData\Local\terminal
,没有这个文件夹新建一个。
留神:[user_name]
是你本人电脑的用户名
0x2 写入注册表
创立一个 txt 文档,并把档后缀改为 reg
。文档的名字可本人创立,后缀名不能够错。右键菜单呈现 Windows Terminal
有两种办法。一种是按 shift
+ 右键
, 另一种是间接 右键
。
shift + 右键
把上面的内容复制到 reg 去
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Directory\Background\shell\wt]
@="Windows Terminal"
"Icon"="%USERPROFILE%\\AppData\\Local\\terminal\\wt_32.ico"
"Extended"=""
[HKEY_CLASSES_ROOT\Directory\Background\shell\wt\command]
@="C:\\Users\\[user_name]\\AppData\\Local\\Microsoft\\WindowsApps\\wt.exe"
留神:请把 [user_name]
改成本人电脑的用户名
右键
把上面的内容复制到 reg 去
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Directory\Background\shell\wt]
@="Windows terminal here"
"Icon"="%USERPROFILE%\\AppData\\Local\\terminal\\wt_32.ico"
[HKEY_CLASSES_ROOT\Directory\Background\shell\wt\command]
@="C:\\Users\\[user_name]\\AppData\\Local\\Microsoft\\WindowsApps\\wt.exe"
留神:请把 [user_name]
改成本人电脑的用户名
0x3 批改 Windows Terminal 的 settings.json
把 profiles > list > startingDirectory
改为 null
,没有的本人创立一个。
能够抉择的改你须要的。(我都改了)
这个是批改右键启动门路为以后运行命令的门路。
0x7 结语
平时工作中命令行 git
命令用的比拟多,装置了扩大,输出命令能够按 Tab
来主动补全不便了很多。
Windows 下的命令行还有很多的玩法,比方反对 Linux 命令的 MSYS2
,集成了 pacman
。能够参考 Win10 终端神器——Windows Terminal 与 MSYS2 MinGW64 集成记 进行装置。
0x8 参考链接
- 举荐一款 颜值爆表的主题终端 (windows), by iwhao_top
- 增加 Windows Terminal 到鼠标右键菜单,by Jerry
对于我
SunSeekerX,前端开发、Nodejs 开发、小程序、uni-app
开发、等等
喜爱探讨技术实现计划和细节,完满主义者,见不得bug
。
Github:https://github.com/SunSeekerX
集体博客:https://yoouu.cn/
集体在线笔记:https://sunseekerx.yoouu.cn/