PowerShell 选项卡完成问题

发布于 2024-10-03 20:59:44 字数 319 浏览 6 评论 0原文

假设我有以下文件夹:C:\[test]\x,那么,当在 [test] 文件夹内时,我无法使用 PowerShell 的 Tab 补全功能全部。

我猜原因是文件夹名称需要转义为 ´[test´] (刻度线颠倒,这会导致此处的 Markdown 问题),就像从 Tab 键切换时完成的那样在 C:\ 内。

我并不真正关心在 C:\ 内部并输入 [t... 时缺少的制表符补全,但我想在其中使用制表符补全文件夹。有什么办法可以解决这种行为吗?

Suppose I have the following folder: C:\[test]\x, then, when inside of the [test] folder, I can't use PowerShell's tab completion at all.

I guess the reason for that is that the folder name would need to be escaped to ´[test´] (with the ticks inverted, which causes Markdown problems here), as it the completion does when tabbing from inside C:\.

I don't really care about the missing tab completion when inside of C:\ and typing [t..., but I would like to use the tab completion within that folder. Is there any way to fix that behaviour?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

静谧幽蓝 2024-10-10 20:59:44

PowerShell 及其许多功能通常不适用于带有特殊符号、[] 符号的路径。我们无法修复 PowerShell 核心,但我们可以修复/替换某些功能。 TabExpansion 就是其中之一。它只是一个全局函数,可以用改进的实现来替换。

可以到处找到几个自定义 TabExpansion 实现。我用的是我自己的。它与主机无关(至少它与控制台、ISE 和我自己的主机配合得很好),它相当简单,但它提供了很多改进。您的具体问题也已解决。

TabExpansion 的代码(点源代码或简单地从您的 PowerShell 配置文件中调用它):
http://code.google.com/p/farnet /source/browse/trunk/PowerShellFar/TabExpansion.ps1

此测试涵盖了它的一些功能:
http://code。 google.com/p/farnet/source/browse/trunk/PowerShellFar/Bench/Test/Test-TabExpansion-.ps1
(测试仅在特殊环境下有效,不要运行,只需看一下代码中的注释,看看TabExpansion能做什么)。

PowerShell and many its features in general do not work well with paths with special symbols, [ and ] symbols in the first place. We cannot fix the PowerShell core but we can fix/replace some features. TabExpansion is one of them. It's just a global function that can be replaced with an improved implementation.

Several custom TabExpansion implementations can be found here and there. I am using my own. It is host agnostic (at least its works well with Console, ISE, and my own host), it is reasonably simple and yet it provides a lot of improvements. Your particular problem is resolved, too.

The code of TabExpansion (dot-source it in or simply call it from your PowerShell profile):
http://code.google.com/p/farnet/source/browse/trunk/PowerShellFar/TabExpansion.ps1

Some of its features are covered by this test:
http://code.google.com/p/farnet/source/browse/trunk/PowerShellFar/Bench/Test/Test-TabExpansion-.ps1
(The test works only in the special environment, do not run it, just take a look at comments in the code to see what TabExpansion can do).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文