docker - 使 PowerShell 推荐像 Linux-bash(例如 docker)

标签 docker powershell autocomplete windows-subsystem-for-linux tab-completion

我的 Windows 10 操作系统启用了 WSL 并安装了适用于 Windows 的 docker。

当我在 PowerShell 中键入 docker 并点击 Tab 键时,它会建议我在工作目录中找到相应的文件夹和文件。

此处 AndroidStudioProjects 是我工作目录中的一个目录。 enter image description here

另一方面, 当我在 WSL Ubuntu 中键入 docker 并点击选项卡时,它会建议可用的 docker 命令本身。 (我的预期行为) enter image description here

我希望PowerShell也像WSL ubuntu一样推荐。

最佳答案

据推测:

    WSL 上的
  • docker 带有用于 POSIX 兼容 shell 的制表符完成功能,例如 bash,通过 shell 的初始化文件安装.

  • 没有为 PowerShell 提供此类支持,但有第三方解决方案 - 见下文。


docker 安装 PowerShell tab-completion:

安装 DockerCompletion module来自 PowerShell 库:

# Install the module in the scope of the current user.
Install-Module DockerCompletion -Scope CurrentUser

# Import the module into the session.
# Add this line to your $PROFILE file to make the tab-completion
# available in future sessions.
Import-Module DockerCompletion 

所有支持的程序(CLI)安装 PowerShell tab 完成:

posh-cli meta-module - 其 repo 是 here - 提供了一种方便的方法为所有本地安装的 CLI 自动安装制表符完成支持,这些 CLI 可以使用特定于应用程序的制表符完成模块:

# Install the meta-module in the scope of the current user.
Install-Module posh-cli -Scope CurrentUser

# This looks for locally installed CLIs for which tab-completion
# modules are available, installs them, and adds
# Import-Module commands to your $PROFILE file.
Install-TabCompletion

参见 the README获取更多信息。

关于docker - 使 PowerShell 推荐像 Linux-bash(例如 docker),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66479577/

相关文章:

jquery - 如何使用自动完成功能更改选择事件上的文本框值(jQuery UI)

docker - Jenkinsfile 无法使用多个参数运行 docker

docker - 用Docker运行Bamboo脚本

docker - 如何在 Bluemix 中连接两个 HA 组容器?

Powershell:压缩文件

javascript - 如何强制 Materialise 自动完成文本流到新行?

Apache 403 Forbidden 您无权访问/在此服务器上

Powershell 给出 Get-Content : Exception of type 'System.OutOfMemoryException' was thrown

powershell - 有没有比输入 | 更快的方法来计算 powershell 中的行数?测量对象

jquery - Ruby on Rails - 简单表单自动完成关联搜索