PowerShell7 设置命令别名

463 阅读1分钟

先放个自己powershell效果图

我是Windows PowerShell7.x + Windows Termainal

image.png

配置命令别名

  1. 先在终端中输入$profile查看配置文件位置
$profile # 如果有则返回配置文件的位置
test-path $Profile # 返回 true或false

2.如果不存在,创建配置文件,执行完后再次验证

New-Item -Path $Profile -ItemType file -Force

3.编辑配置文件

notepad $PROFILE # 会通过记事本打开

4.新建一个git status的命令别名gs

Function GITSTATUS          { git status  }
Set-Alias -Name gs        -Value GITSTATUS 

写完后保存关闭,然后再终端中输入下面命令刷新配置

. $profile

image.png

同理也可以创建一些yarn serve,pnpm run dev的别名命令

image.png

vscode中同样可用

image.png