Windows powershell7 alias 自定义命令别名

304 阅读1分钟

开启命令执行权限

Set-ExecutionPolicy RemoteSigned

查看powershell配置文件位置

echo $profile;
// 输出示例 
C:\Users\Administrator\Documents\PowerShell\Microsoft.PowerShell_profile.ps1

编辑/新建文件

// 不携带参数
set-alias -Name [name] -Value [comand|string|可执行文件]

// 携带参数 `${$}` 为输入的参数内容
function [name] { [command] ${$} }

// 示例
set-alist -Name g -Valie git
function gst {git status}