Using GitHub Copilot in PowerShell Terminal

如果在终端里面也可以使用github copilot将会方便很多,很多命令不用刻意去记忆,也不用去网上找很久。

先去下载Github-CLI
然后用gh auth login登陆,默认是不安装copilot的,要手动安装插件gh extension install github/gh-copilot

测试一下gh copilot是不是正常使用。

然后设置别名,方便使用。
通过读取配置文件echo $PROFILE的路径,然后修改notepad $PROFILE
加入以下内容。

1
2
3
4
5
function Github-Copilot-Explain { gh copilot explain $args }
function Github-Copilot-Suggest { gh copilot suggest $args }

Set-Alias -Name cs -Value Github-Copilot-Suggest
Set-Alias -Name ce -Value Github-Copilot-Explain

It would be much more convenient if you could also use GitHub Copilot in the terminal, saving you from deliberately memorizing many commands or spending a long time searching online.

First, go and download GitHub CLI.
Then log in using gh auth login. Copilot is not installed by default; you need to manually install the plugin with gh extension install github/gh-copilot.

Test whether gh copilot is working properly.

Then set up aliases for easier use.
By reading the configuration file path with echo $PROFILE, then modify it with notepad $PROFILE.
Add the following content.

1
2
3
4
5
function Github-Copilot-Explain { gh copilot explain $args }
function Github-Copilot-Suggest { gh copilot suggest $args }

Set-Alias -Name cs -Value Github-Copilot-Suggest
Set-Alias -Name ce -Value Github-Copilot-Explain

Using GitHub Copilot in PowerShell Terminal
https://tokisaki.top/blog/github-copilot/
作者
Tokisaki Galaxy
发布于
2023年12月20日
许可协议