准备
- Windows Terminal
- Windows 10 应用商店(Windows Store)下载安装即可
- PowerShell Core v7.0.1
- PowerShell-7.1.0-win-x64.msi
配置 Windows Terminal
打开Settings,编辑settings.json,为 PowerShell Core 先生成一个GUID,比如用 Online GUID Generator
在 list 中添加一项,如下:
代码语言:javascript复制{
"guid": "{be8c6241-aafb-437f-8d7c-a7142adf7f54}",
"name": "PowerShell Core",
"commandline": "D:\Program Files\PowerShell\7\pwsh.exe",
"icon": "D:\Program Files\PowerShell\7\assets\ps_black_32x32.ico",
"hidden": false
},
注意:更改 commandline,icon 路径为你的安装路径
添加 Windows Terminal 到右键菜单
代码语言:javascript复制注意: 新版安装后会自动添加到右键菜单, 已经不再需要手动添加 创建txt文件,内容为下方,注意:icon图标地址,与 yiyun 用户名 需修改 修改文件名为
添加右键菜单.reg
,双击运行即可
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOTDirectoryBackgroundshellwt]
@="Windows Terminal here"
"Icon"="F:\Com\tools\WindowsTerminal\terminal.ico"
[HKEY_CLASSES_ROOTDirectoryBackgroundshellwtcommand]
@="C:\Users\yiyun\AppData\Local\Microsoft\WindowsApps\wt.exe"
完整配置参考
代码语言:javascript复制// This file was initially generated by Windows Terminal 1.1.2021.0
// It should still be usable in newer versions, but newer versions might have additional
// settings, help text, or changes that you will not see unless you clear this file
// and let us generate a new one for you.
// To view the default settings, hold "alt" while clicking on the "Settings" button.
// For documentation on these settings, see: https://aka.ms/terminal-documentation
{
"$schema": "https://aka.ms/terminal-profiles-schema",
"defaultProfile": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
// You can add more global application settings here.
// To learn more about global settings, visit https://aka.ms/terminal-global-settings
// If enabled, selections are automatically copied to your clipboard.
"copyOnSelect": false,
// If enabled, formatted data is also copied to your clipboard
"copyFormatting": false,
// A profile specifies a command to execute paired with information about how it should look and feel.
// Each one of them will appear in the 'New Tab' dropdown,
// and can be invoked from the commandline with `wt.exe -p xxx`
// To learn more about profiles, visit https://aka.ms/terminal-profile-settings
"profiles": {
"defaults": {
// Put settings here that you want to apply to all profiles.
"acrylicOpacity": 0.9,
"colorScheme": "Dark ",
"fontFace": "DejaVu Sans Mono for Powerline",
"hidden": false,
"useAcrylic": false, //true,
"startingDirectory": "." // 起始目录为当前打开目录
// "backgroundImage": "F://Com//tools//WindowsTerminal//background.gif", // 图片地址
// "backgroundImageOpacity" : 0.15, // 透明度
// "backgroundImageStretchMode": "fill" // 填充模式
},
"list": [
{
"guid": "{be8c6241-aafb-437f-8d7c-a7142adf7f54}",
"name": "PowerShell Core",
"commandline": "D:\Program Files\PowerShell\7\pwsh.exe",
"icon": "D:\Program Files\PowerShell\7\assets\ps_black_32x32.ico",
"hidden": false
},
{
// Make changes here to the powershell.exe profile.
"guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
"name": "Windows PowerShell",
"commandline": "powershell.exe",
"hidden": false
},
{
// Make changes here to the cmd.exe profile.
"guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
"name": "命令提示符",
"commandline": "cmd.exe",
"hidden": false
},
{
"guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}",
"hidden": false,
"name": "Azure Cloud Shell",
"source": "Windows.Terminal.Azure"
},
{
"guid": "{4c18d1cd-6d8d-426a-be2f-a4b3152a32c4}",
"hidden": false,
"name": "Python 3.8.6rc1",
"commandline": "D:\Program Files\python38\python.exe",
"icon": "D:\Program Files\python38\DLLs\pyc.ico"
},
{
"guid": "{1c4de342-38b7-51cf-b940-2309a097f589}",
"hidden": false,
"name": "Git Bash",
"commandline": "D:\Program Files\Git\bin\bash.exe",
"acrylicOpacity": 0, // 透明度
"closeOnExit": true, // 关闭的时候退出命令终端
"cursorColor": "#FFFFFF", // 光标颜色
"cursorShape": "bar", // 光标形状
"fontFace": "YaHei Consolas Hybrid", // 字体配置,选择你电脑上已安装的字体
"fontSize": 14, // 终端字体大小
"icon": "D:\Program Files\Git\mingw64\share\git\git-for-windows.ico", // git的图标
"historySize": 9001, // 终端窗口记忆大小
"padding": "0, 0, 0, 0", // 边距
"snapOnInput": true,
"useAcrylic": false // 是否开启透明度
}
]
},
// Add custom color schemes to this array.
// To learn more about color schemes, visit https://aka.ms/terminal-color-schemes
"schemes": [
{
"name": "Japanesque",
"black": "#343935",
"red": "#cf3f61",
"green": "#7bb75b",
"yellow": "#e9b32a",
"blue": "#4c9ad4",
"purple": "#a57fc4",
"cyan": "#389aad",
"white": "#fafaf6",
"brightBlack": "#595b59",
"brightRed": "#d18fa6",
"brightGreen": "#767f2c",
"brightYellow": "#78592f",
"brightBlue": "#135979",
"brightPurple": "#604291",
"brightCyan": "#76bbca",
"brightWhite": "#b2b5ae",
"background": "#1e1e1e",
"foreground": "#f7f6ec"
},
{
"name": "Snazzy",
"black": "#000000",
"red": "#fc4346",
"green": "#50fb7c",
"yellow": "#f0fb8c",
"blue": "#49baff",
"purple": "#fc4cb4",
"cyan": "#8be9fe",
"white": "#ededec",
"brightBlack": "#555555",
"brightRed": "#fc4346",
"brightGreen": "#50fb7c",
"brightYellow": "#f0fb8c",
"brightBlue": "#49baff",
"brightPurple": "#fc4cb4",
"brightCyan": "#8be9fe",
"brightWhite": "#ededec",
"background": "#1e1f29",
"foreground": "#ebece6"
},
{
"name": "Dark ",
"black": "#000000",
"red": "#cd3131",
"green": "#0dbc79",
"yellow": "#e5e510",
"blue": "#2472c8",
"purple": "#bc3fbc",
"cyan": "#11a8cd",
"white": "#e5e5e5",
"brightBlack": "#666666",
"brightRed": "#f14c4c",
"brightGreen": "#23d18b",
"brightYellow": "#f5f543",
"brightBlue": "#3b8eea",
"brightPurple": "#d670d6",
"brightCyan": "#29b8db",
"brightWhite": "#e5e5e5",
"background": "#0e0e0e",
"foreground": "#cccccc"
}
],
// Add custom keybindings to this array.
// To unbind a key combination from your defaults.json, set the command to "unbound".
// To learn more about keybindings, visit https://aka.ms/terminal-keybindings
"keybindings": [
// Copy and paste are bound to Ctrl Shift C and Ctrl Shift V in your defaults.json.
// These two lines additionally bind them to Ctrl C and Ctrl V.
// To learn more about selection, visit https://aka.ms/terminal-selection
{ "command": { "action": "copy", "singleLine": false }, "keys": "ctrl c" },
{ "command": "paste", "keys": "ctrl v" },
// Press Ctrl Shift F to open the search box
{ "command": "find", "keys": "ctrl shift f" },
// Press Alt Shift D to open a new pane.
// - "split": "auto" makes this pane open in the direction that provides the most surface area.
// - "splitMode": "duplicate" makes the new pane use the focused pane's profile.
// To learn more about panes, visit https://aka.ms/terminal-panes
{
"command": {
"action": "splitPane",
"split": "auto",
"splitMode": "duplicate"
},
"keys": "alt shift d"
}
]
}
备份
background.gif
Q&A
补充
git log, git diff 中文乱码(Hex码)
PowerShell 执行下方
代码语言:javascript复制git config --global core.quotepath false
git config --global gui.encoding utf-8
git config --global i18n.commit.encoding utf-8
git config --global i18n.logoutputencoding utf-8
$env:LESSCHARSET='utf-8'
添加系统环境变量
点击Ok ,完成后,关闭 Windows Terminal,重新打开,输入下方命令验证是否成功
代码语言:javascript复制$env:LESSCHARSET
解决,无论是 git log,还是 git diff, 中文都显示正常
rz
参考:
- Feature Request: Zmodem/lrzsz support · Issue #1602 · microsoft/terminal
暂时不支持
添加 SSH 连接
代码语言:javascript复制{
"guid": "{4360b1d2-9732-4bfd-8967-93338bcbb568}",
"hidden": false,
"name": "Aliyun ECS",
"commandline": "ssh root@120.55.193.95",
"icon": "ms-appx:///ProfileIcons/{9acb9455-ca41-5af7-950f-6bca1bc9722f}.png"
}
参考
感谢帮助!
- Windows Terminal 完美配置 PowerShell 7.1
- 新发布的Windows Terminal如何添加到右键菜单?
- PowerShell | git log 中文乱码问题解决
本文作者: yiyun
本文链接: https://cloud.tencent.com/developer/article/1970678
版权声明: 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!