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/...

相关推荐
xuhe21 小时前
掌控Coding Plan刷新节奏, 低价套餐满足高峰时期编程需求 -- Quota-Activator
ai·github
Mintimate1 小时前
LeanCloud 遗憾谢幕:基于 EdgeOne KV 打造高性能 PV/UV 访客统计
serverless·github·边缘计算
犽戾武4 小时前
Ubuntu(Orange Pi / RK3588)把工程上传到 GitHub 的完整流程总结(Windows差不多)
github
CoderJia程序员甲5 小时前
GitHub 热榜项目 - 日榜(2026-02-18)
人工智能·ai·大模型·github·ai教程
人道领域6 小时前
SpringBoot多环境配置实战指南
java·开发语言·spring boot·github
7yewh6 小时前
Top 10 Trending GitHub Projects - February 2026(1)
github
CoderJia程序员甲6 小时前
GitHub 热榜项目 - 日榜(2026-02-20)
人工智能·ai·大模型·github·ai教程
此生只爱蛋6 小时前
【Redis】渐进式遍历
数据库·redis·github
Desirediscipline21 小时前
#define _CRT_SECURE_NO_WARNINGS 1
开发语言·数据结构·c++·算法·c#·github·visual studio
uhakadotcom1 天前
Hono v4.12.0 发布!路由提速2倍+,JSON响应飞起来
前端·面试·github