Windows 11技巧:使用Powershell定义命令别名
在linux上很容易定义给长命令定义一个短的别名,windows 11上怎么做呢?
-
检查profile文件是否存在
test-path $profile -
如果不存在,则创建它
new-item -path $profile -type file -force -
用记事本打开
notepad $profile -
定义函数
function dc {
docker-compose $args
} -
设置执行策略,并加载profile(如果不设置策略,可能会无法加载)
Set-ExecutionPolicy -Scope CurrentUser RemoteSigned
. $profile -
试一下dc命令是否可用
dc --help