windows 11 配置 alias

最近入职新公司,没mac用了,配了windows 11的办公机器。

又因为windows的命令和linux/mac这些系统有很大的差异,这边懒癌发作,没去咋折腾。

终于在手动敲了四周的git status, git rebase, git pull --rebase后,我受不了了,决心把alias给搞一下。

PowerShell

windows 11 有PowerShell, goland 默认也是用的PowerShell,而不是很老的windows那个命令提示符。 所以这里只讲PowerShell的。

找到配置文件的绝对路径

在Powershell的控制台中,输入echo $profile

这个就是PowerShell的配置文件地址。如果这个文件不存在的话,需要自己手动创建

我的机器上也没有这个文件,于是创建了一个

shell 复制代码
## windows下的创建命令,注意自己换路径哦
 Invoke-Item -Path C:\Users\xxx\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1

添加alias别名

用任意编辑器打开Microsoft.PowerShell_profile.ps1文件,添加函数比如

typescript 复制代码
Function gba(){
     git branch -a
}

Function gco([string]$branch){
     git checkout $branch
}

Function gst(){
     git status
}

Function gpr(){
     git pull --rebase
}

我这里全都是单条命令的,其实能写多条命令的,具体自己摸索下

重启PowerShell并使用

能看到alias已经生效了,哎舒服了

相关参考

cloud.tencent.com/developer/a... blog.csdn.net/a772304419/...

相关推荐
CoderJia程序员甲14 小时前
GitHub 热榜项目 - 日榜(2026-02-17)
ai·大模型·github·ai教程
Kusunoki_D14 小时前
在GitHub Pages仓库上设置个人网页
github
嫂子开门我是_我哥14 小时前
GitHub介绍指南
github
阿里嘎多学长1 天前
2026-02-16 GitHub 热点项目精选
开发语言·程序员·github·代码托管
xuhe21 天前
Mihon/Tachiyomi漫画插件分析(侧重目前插件现状分析和英文插件推荐)
github·tachiyomi
小锋学长生活大爆炸1 天前
【教程】PicoClaw:在嵌入式设备上部署OpenClaw
docker·github·教程·工具·openclaw·picoclaw
secondyoung1 天前
Git使用:Git使用问题及解决方法总结
windows·经验分享·git·vscode·gitee·github·gitcode
程序员敲代码吗1 天前
提升Redis性能的关键:深入探讨主从复制
数据库·redis·github
CoderJia程序员甲2 天前
GitHub 热榜项目 - 日榜(2026-02-16)
大模型·llm·github·ai教程
Wcowin2 天前
【2】 Zensical配置详解
前端·github