背景
windows terminal使用起来挺顺手,不过若进行需管理员权限的操作时,有点不太方便。可将其添加到菜单,方便使用。
步骤
1,安装gsudo
choco install gsudo
2,安装一个文本编辑器,例如vscode。如果已有,跳过此步。(windows terminal默认使用vscode作为其编辑器)
3,运行windows terminal,打开"设置"菜单,在配置settings.json文件中,添加如下第一个节点。然后重开windows terminal便可。
小贴士
windows terminal 启动后默认的页签是powershell。如果想让管理员cmd作为默认,可修改此配置文件为:"defaultProfile": "{41dd7a51-f0e1-4420-a2ec-1a7130b7e950}",//"{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
"list": [
{
"guid": "{41dd7a51-f0e1-4420-a2ec-1a7130b7e950}",
"name": "命令提示符(管理员)",
"commandline": "gsudo.exe 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
},
{
// Make changes here to the cmd.exe profile.
"guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
"name": "命令提示符",
"commandline": "cmd.exe",
"hidden": false
},
{
"guid": "{07b52e3e-de2c-5db4-bd2d-ba144ed6c273}",
"hidden": false,
"name": "Ubuntu-20.04",
"source": "Windows.Terminal.Wsl"
},
{
"guid": "{c6eaf9f4-32a7-5fdc-b5cf-066e8a4b1e40}",
"hidden": false,
"name": "Ubuntu-18.04",
"source": "Windows.Terminal.Wsl"
},
{
"guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}",
"hidden": false,
"name": "Azure Cloud Shell",
"source": "Windows.Terminal.Azure"
}