4

为 PowerShell 设置 alias

 2 years ago
source link: https://hellodk.cn/post/935
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

为 PowerShell 设置 alias

打开 PowerShell,执行

echo $profile

查看输出,我的是 C:\Users\dk\OneDrive\文档\WindowsPowerShell\Microsoft.PowerShell_profile.ps1

再查看该文件是否存在,如果没有则手动创建(是一个纯文本文件)

结合上一篇文章:在 vscode 默认终端 PowerShell 快速打开当前路径下的 Git Bash 窗口 ,我们为 d:\git-bash.bat 创建一个 alias,名为 gitbash,让用户输入 gitbash 即可打开当前路径下的 Git Bash 窗口。

编辑 C:\Users\dk\OneDrive\文档\WindowsPowerShell\Microsoft.PowerShell_profile.ps1,输入以下内容

function gitbash {d:\git-bash.bat}

保存即可。现在用户在 PowerShell 中输入 gitbash 即可打开当前路径下的 Git Bash 窗口。

此功能的更多详细用法,请自行搜索,本文就是这么简单。

标签: Windows, 技巧

本作品采用 知识共享署名-相同方式共享 4.0 国际许可协议 进行许可。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK