Windows PowerShell 指令别名

1.创建并修改Windows Powershell 启动执行文件

  • 以管理员身份运行 Powershell
  • 执行 echo $PROFILE 出现如下图所示内容

    根据上图路径查找本地文件, 没有对应文件夹就创建对应文件夹及文件,(注意英文翻译) 比如 文档 就是 Documents

if (!(Test-Path -Path $PROFILE)) { New-Item -Type File -Path $PROFILE -Force } notepad $PROFILE
创建自定义别名文件

2.按格式输入命令

  • `function 别名 { 需要替代的命令 }`
    
  • 例如 pnpm 别名为 p
    
  • `function pv { pnpm dev }`
    
  •  Set-Alias p pnpm
    

3 执行设定

  • 以管理员 身份打开Powershell 执行命令 Set-ExecutionPolicy RemoteSigned

4 重启Powershell 大功告成

posted @ 2024-07-11 15:07  a阿童木  阅读(55)  评论(0)    收藏  举报