0%

在Windows Terminal中使用Github Copilot

微软近期在其Windows Terminal的Canary版本中引入了Terminal Chat功能,这一创新允许用户与AI服务(例如GitHub Copilot)进行交互,从而获得与上下文紧密相关的智能建议。经过初步体验,我发现其效果颇为显著。

要开始使用,可以下载Canary版本的Windows Terminal,并在设置页面的Terminal Chat选项卡中完成对GitHub Copilot的配置。这样就可以在不离开终端的情况下,轻松地与Copilot进行对话,获取命令建议与解释。

作为一名后端工程师,知晓如何在PowerShell中查询使用特定端口的进程、可执行文件的路径以及该进程的运行命令是很有价值的技能。目前,我所知的方法仅限于使用netstat来查询使用特定端口的进程PID。

以下是我与GitHub Copilot的对话记录:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
User:
找到使用8000端口的进程、可执行文件地址和运行命令
Assistant:
To find the process, executable file path, and running command for the process using port 8000 in Windows Terminal with pwsh.exe, you can use the `Get-NetTCPConnection` and `Get-Process` cmdlets. Please follow the steps below:
1. Open Windows Terminal and launch pwsh.exe.
2. Run the following command to find the process using port 8000:
Get-NetTCPConnection | Where-Object {$_.LocalPort -eq 8000}
3. Note the value in the `OwningProcess` column. This is the Process ID (PID) of the process using port 8000.
4. Run the following command to find the executable file path of the process:
(Get-Process -Id [PID]).Path
Replace `[PID]` with the actual Process ID obtained in the previous step.
5. Run the following command to find the running command of the process:
(Get-Process -Id [PID] | Select-Object -ExpandProperty CommandLine)
Replace `[PID]` with the actual Process ID obtained in the first step.
These commands will allow you to identify the process, executable file path, and running command for the process using port 8000 in Windows Terminal with pwsh.exe.

为了验证这些步骤,我首先使用miniserve运行了一个使用8000端口的静态HTTP服务:

1
miniserve -p 8000 .

随后,我严格按照Copilot的指示操作,并成功地获取了进程的PID、可执行文件的路径以及该进程的运行命令。

terminal-chat

总的来说,这次体验相当令人满意。

扫码加入技术交流群🖱️
QR code