Make PowerShell recommendation like Linux-bash (E.g. docker)

Viewed 1142

I have windows 10 OS with WSL enabled and docker for windows installed.

When I type docker in PowerShell and hit tab, it suggests me with the corresponding folders and files in my working directory.

here AndroidStudioProjects is a directory in my working directory. enter image description here

On the other hand, When I type docker in WSL Ubuntu and hit tab, it suggests the available docker commands themselves. (My expected behavior) enter image description here

I want PowerShell to also recommend like WSL ubuntu.

1 Answers

Presumably:

  • docker on WSL comes with tab-completion for POSIX-compatible shells such as bash, installed via the shell's initialization files.

  • no such support is provided for PowerShell, but there are third-party solutions - see below.


Installing PowerShell tab-completion for docker:

Install the DockerCompletion module from the PowerShell Gallery:

# 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 

Installing PowerShell tab-completion for all supported programs (CLIs):

The posh-cli meta-module - whose repo is here - offers a convenient way to automatically install tab-completion support for all locally installed CLIs for which application-specific tab-completion modules are available:

# 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

See the README for more information.

Related