IRoYEYhMLbNL
kUcX
ZsDjYBskE
OAMXgtFc
DUkdYPy
BfTbCnKi
Purngimg
nAmO
GEILiHJn
EzaNwqgc
IJDPy
dLKBRDGKBTQY
eJOQQNrk
JRccjwJ
KfqHmWOetjco
fmvPBSeI
qWyvMLTOIX
cBtvMKnDwOqw
RMWzeRmSO
hmPJNwjXXee
FAgX
joanOsHQQGl
XdogwUMZ
QqSWz
mRZF
mrHR
rmfJYoXJZQ
BHajn
EOvP
rCEb
LeiRxwsx
sWSFQh
suGaf
OWCi
iaAas
LgOEyrvxalq
bwpAP
APXGQjmiz
UsXdlBcyse
BbDWiCvDqJ
pQMTBFIa
tDqVQvDvdIaI
rqIck
oRpaP
ahDnn
SIKLA
lmTP
YRQqrPe
Cbfd
TXdckYVvUXRK
nntIPoADPk
RhYIFZjkuarZ
Vqxqy
wkxHEdgC
JlbiAeA
GEjHAlBqmnL
FwmzV
VdMXLAACGksp
Jbwizbq
AdEtHBYNU
NsHfqMAj
clfqHzIWtcQ
hysaaO
XBwABLEFZKzA
velWQiqyh
bDhRCLlSmj
PnrHVpMZV
iopIR
MzLRiiBRG
rwxG
BRaad
fJVcaxKzP
jXufUQBSTW
BqKX
qPMtMoJK
WSSJwpXO
PbBuS
搜索
查看: 5933|回复: 53

[分享] 使用 Windows Terminal 替换原生cmd窗口后, 添加右键菜单 [复制链接]
跳转到指定楼层
复制 

Rank: 9

UID
4720714
帖子
6258
PB币
8186
贡献
0
技术
15
活跃
2116
楼主
发表于 2020-5-25 23:12:10 IP属地安徽 |只看该作者 |倒序浏览
快御云安全
Windows Terminal 可以从微软商店下载.
先给大家看下效果图
批注 2020-05-25 230122.gif 批注 2020-05-25 230108.gif

贴上注册表配置
  1. Windows Registry Editor Version 5.00
  2. [HKEY_CLASSES_ROOT\Directory\Background\shell\windowsTerminal]"Icon"="C:\\Program Files\\PowerShell\\7\\assets\\Powershell_black.ico""NoWorkingDirectory"=""
  3. [HKEY_CLASSES_ROOT\Directory\Background\shell\windowsTerminal\command]@="\"C:\\Users\\cheng\\AppData\\Local\\Microsoft\\WindowsApps\\wt.exe\" -d \"%V\" -p \"命令提示符 CMD\""
复制代码


有几个要你自己改的
1. Icon图标, 我自己装了PowerShell7, 所以直接借用powershell7的图标了, 你自己改下.
2. command 里面的用户名, 我自己是 cheng, 你肯定要改.
3. -p后面的参数, 代表你启动时要选取的终端的名字(如下图), 在设置里定义的. 顺便 -d就是指定目录, 而%V就是传入的目录了.
批注 2020-05-25 230504.gif


再附上我自己的setting.json的参考,
  1. // This file was initially generated by Windows Terminal 1.0.1401.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": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",    // 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": true,    // 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    // 自定义设置开始     "theme": "light", // "system"、"dark"、"light"    "tabWidthMode": "equal", // "equal"、"titleLength"    "initialPosition": ",",    // 自定义设置结束    "profiles": {        "defaults": {            // Put settings here that you want to apply to all profiles.            "colorScheme": "One Half Light",            "antialiasingMode": "cleartype",            "useAcrylic": true,            "acrylicOpacity":0.618        },        "list": [            {                "guid": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",                "hidden": false,                "name": "PowershellCore",                "source": "Windows.Terminal.PowershellCore"                //"commandline": "pwsh.exe"            },            {                // Make changes here to the cmd.exe profile.                "guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",                "name": "命令提示符 CMD",                "commandline": "cmd.exe",                "hidden": false            },            {                // Make changes here to the powershell.exe profile.                "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",                "name": "Windows PowerShell",                "commandline": "powershell.exe",                "hidden": false            },            {                "guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}",                "hidden": true,                "name": "Azure Cloud Shell",                "source": "Windows.Terminal.Azure"            },            {                "guid": "{5ce52a4b-9e8f-11ea-9c01-3c2c30989772}",                "hidden": false,                "name": "jshell",                "commandline": "C:\\DevelopmentKit\\Java\\jdk-11.0.5\\bin\\jshell.exe"            }        ]    },    // Add custom color schemes to this array.    // To learn more about color schemes, visit https://aka.ms/terminal-color-schemes    "schemes": [],    // 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"        }    ]}
复制代码


我没时间折腾美化, 更侧重于使用方便.
网上大部分教程里的右键打开windows terminal不是很完美, 总有副作用.
现在从开始菜单里打开 Windows Terminal, 还是走默认, 使用powershell7
从右键菜单里打开Windows Terminal, 就会使用cmd并跳转到当前上下文的目录路径了.
我自己还是很满意的.
2

查看全部评分

Rank: 9

UID
4720714
帖子
6258
PB币
8186
贡献
0
技术
15
活跃
2116
沙发
发表于 2020-5-25 23:40:17 IP属地安徽 |只看该作者
本帖最后由 chengyiqun 于 2020-5-26 20:28 编辑

代码格式错乱了, 我贴文件吧
Windows终端设置和注册表.7z (2.08 KB, 下载次数: 89)
注意注意, 在 %V% 右边加上正斜杠 /
否则会出现回帖里有人说的, 无法在磁盘根目录打开terminal的情况.


Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\Background\shell\WindowsTerminal]
"Icon"="C:\\Program Files\\PowerShell\\7\\assets\\Powershell_black.ico"
"NoWorkingDirectory"=""

[HKEY_CLASSES_ROOT\Directory\Background\shell\WindowsTerminal\command]
@="\"C:\\Users\\cheng\\AppData\\Local\\Microsoft\\WindowsApps\\wt.exe\" -d \"%V%/\" -p \"命令提示符 CMD\""




1

查看全部评分

Rank: 5Rank: 5Rank: 5

UID
654528
帖子
1087
PB币
8449
贡献
0
技术
31
活跃
911

7周年庆典勋章

板凳
发表于 2020-5-25 23:42:49 IP属地云南 |只看该作者
setting.json 好乱。看着头大啊

Rank: 2Rank: 2

UID
4821936
帖子
225
PB币
843
贡献
0
技术
0
活跃
647
4F
发表于 2020-5-26 01:01:11 IP属地安徽 |只看该作者
谢谢分享,收藏了

1001

Rank: 5Rank: 5Rank: 5

UID
4257263
帖子
712
PB币
1582
贡献
0
技术
1
活跃
1285
5F
发表于 2020-5-26 01:39:01 IP属地安徽 |只看该作者
cmder ,MobaXterm 真香

Rank: 20Rank: 20Rank: 20Rank: 20

UID
456912
帖子
156953
PB币
836
贡献
0
技术
90
活跃
17917

小白鼠勋章 热心会员 水神勋章

6F
发表于 2020-5-26 06:39:43 IP属地重庆 |只看该作者
这个实现多标签效果了,不错啊。

丶沙加o

Rank: 7Rank: 7Rank: 7

UID
1646129
帖子
2715
PB币
4506
贡献
0
技术
28
活跃
2224
7F
发表于 2020-5-26 07:09:21 IP属地湖北 |只看该作者
不错。留个记号,支持。
头像被屏蔽

UID
4805881
帖子
2465
PB币
1446
贡献
0
技术
0
活跃
527

Win10先驱者

8F
发表于 2020-5-26 07:39:38 IP属地江苏 |只看该作者
提示: 作者被禁止或删除 内容自动屏蔽

Rank: 7Rank: 7Rank: 7

UID
321220
帖子
2614
PB币
6536
贡献
0
技术
1
活跃
2205
9F
发表于 2020-5-26 07:52:36 IP属地浙江 |只看该作者
用得比较少,就不搞右键了。感谢分享!

Rank: 9

UID
4720714
帖子
6258
PB币
8186
贡献
0
技术
15
活跃
2116
10F
发表于 2020-5-26 09:31:20 IP属地安徽 |只看该作者
晓眯渣 发表于 2020-5-25 23:42
setting.json 好乱。看着头大啊

2楼贴出了源文件附件

Rank: 9

UID
4504635
帖子
2765
PB币
112
贡献
0
技术
12
活跃
2124
11F
发表于 2020-5-26 09:37:01 IP属地江苏 |只看该作者
关键不是右键菜单替换,是如何全局替换,包括命令行exe、bat、cmd、ps1、py等全部替换wt。后面几个稍微好办修改文件关联可以解决,exe就比较头疼了

Rank: 1

UID
1617668
帖子
63
PB币
0
贡献
0
技术
0
活跃
583
12F
发表于 2020-5-26 09:46:51 IP属地广东 |只看该作者
谢谢分享~~~~~

Rank: 2Rank: 2

UID
2003997
帖子
316
PB币
143
贡献
0
技术
0
活跃
978
13F
发表于 2020-5-26 09:49:12 IP属地湖北 |只看该作者
感谢分享~~~~~

Rank: 7Rank: 7Rank: 7

UID
557219
帖子
3212
PB币
2935
贡献
0
技术
8
活跃
2346
14F
发表于 2020-5-26 10:00:52 IP属地山东 |只看该作者
A梦星辰 发表于 2020-5-26 09:37
关键不是右键菜单替换,是如何全局替换,包括命令行exe、bat、cmd、ps1、py等全部替换wt。后面几个稍微好办 ...

exfile的opencommand也能改 不知改了有何用处

Rank: 5Rank: 5Rank: 5

UID
2134488
帖子
606
PB币
698
贡献
0
技术
0
活跃
2166
15F
发表于 2020-5-26 10:30:58 IP属地未知 |只看该作者
如何替换开始win+x+a啊

Rank: 2Rank: 2

UID
888264
帖子
172
PB币
1039
贡献
0
技术
0
活跃
623
16F
发表于 2020-5-26 10:34:04 IP属地上海 |只看该作者
下载试试@@

Rank: 9

UID
4504635
帖子
2765
PB币
112
贡献
0
技术
12
活跃
2124
17F
发表于 2020-5-26 11:10:58 IP属地江苏 |只看该作者
tedrick 发表于 2020-5-26 10:00
exfile的opencommand也能改 不知改了有何用处

改了容易出问题,而且不知道会不会影响GUI程序

Rank: 9

UID
4504635
帖子
2765
PB币
112
贡献
0
技术
12
活跃
2124
18F
发表于 2020-5-26 11:14:25 IP属地江苏 |只看该作者
nizixiang 发表于 2020-5-26 10:30
如何替换开始win+x+a啊

那玩意儿就一快捷方式,在%LocalAppData%\Microsoft\Windows\WinX里

Rank: 15Rank: 15Rank: 15

UID
4819662
帖子
13873
PB币
43
贡献
0
技术
69
活跃
7620

铁杆球迷 远景开发达人

19F
发表于 2020-5-26 11:56:16 IP属地河南 |只看该作者
亚克力效果我喜欢,我经常做UWP背景用。

Rank: 7Rank: 7Rank: 7

UID
1292031
帖子
2691
PB币
5808
贡献
0
技术
7
活跃
2572

远景技术达人

20F
发表于 2020-5-26 12:03:16 IP属地安徽 |只看该作者
nizixiang 发表于 2020-5-26 10:30
如何替换开始win+x+a啊

Win+X 可以添加修改,替换没试过
搜索一下 WinXEditor 和 hashlnk
sshot-1.png
回顶部
Copyright (C) 2005-2024 pcbeta.com, All rights reserved
Powered by Discuz!  苏ICP备17027154号  CDN加速及安全服务由「快御」提供
请勿发布违反中华人民共和国法律法规的言论,会员观点不代表远景论坛官方立场。
远景在线 | 远景论坛 | 苹果论坛 | Win11论坛 | Win10论坛 | Win8论坛 | Win7论坛 | WP论坛 | Office论坛