Skip to content

Instantly share code, notes, and snippets.

@Codennnn
Last active April 15, 2022 07:48
Show Gist options
  • Save Codennnn/3a07b36549719bd4248fafe1bebb4b68 to your computer and use it in GitHub Desktop.
Save Codennnn/3a07b36549719bd4248fafe1bebb4b68 to your computer and use it in GitHub Desktop.
Windows Terminal 使用教程

美化

安装主题

执行以下命令安装posh-git和oh-my-posh两个模块,遇到提示选y确认即可

Install-Module posh-git -Scope CurrentUser 
Install-Module oh-my-posh -Scope CurrentUser

新增配置文件

如果之前没有配置文件,就新建一个 PowerShell 配置文件

if (!(Test-Path -Path $PROFILE )) { New-Item -Type File -Path $PROFILE -Force }

用记事本打开配置文件

notepad $PROFILE

在其中写入以下内容

Import-Module posh-git 
Import-Module oh-my-posh 
Set-PoshPrompt Paradox

遇到的问题

无法加载文件 ******.ps1,因为在此系统中禁止执行脚本。有关详细信息,请参阅 "get-help about_signing" 使用管理员身份运行 PowerShell,执行 set-ExecutionPolicy RemoteSigned

添加至右键菜单

1.在命令行工具中分别输入这两个命令:echo %USERPROFILE%echo %LOCALAPPDATA%,能正常查看输出信息

2.创建一个文件夹存放 ico 图标,图标的下载链接为:https://gitee.com/Jioho/img/raw/master/wsl/terminal.ico

3.新建一个后缀名为 .reg 的文件,文件名随意,比如 abc.reg

4.在建好的 reg 文件填入以下文本,[] 中需要更改成你电脑中相应的路径

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\Background\shell\wt]
@="Windows Terminal here"
"Icon"="%USERPROFILE%\\AppData\\Local\\Terminal\\terminal.ico"

[HKEY_CLASSES_ROOT\Directory\Background\shell\wt\command]
@="C:\\Users\\[!!你的电脑用户名!!]\\AppData\\Local\\Microsoft\\WindowsApps\\wt.exe"

5.双击执行 reg 文件后,此时就会发现右键菜单新增了 Windows Terminal here 的选项

6.打开 Windows Terminal 的配置文件,修改 startingDirectory 的值为 ./ 即 "startingDirectory": "./",此步骤的目的修改终端打开的相对路径

7.[可选] 如何修改 Windows Terminal here 选项的名称?通过快捷键 window + r 打开运行命令,输入 regedit 打开注册表, 在路径导航中输入 “计算机\HKEY_CLASSES_ROOT\Directory\Background\shell\wt”,选中 wt 就能看到有一个 (默认) 的值,修改此值就行了

8.[可选] 如何删除右键选项?把 “7.” 步骤中打开的 wt 删除就行了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment