posh-HumpCompletion in Azure Cloud Shell


Azure Cloud Shell is an in-browser shell experience that you can launch from the Azure portal or on its own at shell.azure.com. You can choose between bash and PowerShell, and both come with a nice range of installed tools (bash, PowerShell). Oh, and you can also use this inside the Visual Studio Code editor as Scott Hanselman shows!

In this short post I’m going to be looking at the PowerShell experience and will walk through setting up Cloud Shell to work with posh-HumpCompletion (a module that adds tab completion richness to PowerShell and which I was inspired to write after working with the verbose clear naming of the Azure cmdlets). You can see a GIF of it in action on the GitHub page.

Launch Azure Cloud Shell

The first step of this is to launch the Cloud Shell: https://shell.azure.com/PowerShell.

Currently the PowerShell experience is in preview and it can take a while to start and connect – hang in there!

If this is your first time using Cloud Shell then it will walk you through configuring a file share. This is then automatically mounted for you in each Cloud Shell session to allow you to save files across sessions. You can even mount it on your local machine to share content from your local machine with Cloud Shell (docs for Windows, Linux, Mac).

Install posh-HumpCompletion

Now that you have Cloud Shell running you can install posh-HumpCompletion from PowerShell Gallery

Install-Module posh-HumpCompletion

Once you have installed the module simply import it to bring posh-HumpCompletion to life

Import-Module posh-HumpCompletion

Add to your $profile

If you want posh-HumpCompletion to be active automatically when you start a new instance of Cloud Shell then simply add an Import-Module to your PowerShell profile. Since this is stored on the cloud drive that you set up when you first started Cloud Shell it will be invoked for each new instance. The following command appends the import to the profile

echo "`nImport-Module posh-HumpCompletion`n" >> $profile

NOTES

One thing to mention is that the PowerShell Cloud Shell has both the Desktop PowerShell (powershell) and PowerShell Core (pwsh) installed, and they share the $profile. So if you use both and add posh-HumpCompletion to your profile you should install it in both environments to avoid errors!

Update: This post originally said that you needed to specify “-Scope CurrentUser” on the Install-Module command, but thanks go to Aleksandar Nikolić for setting me straight and teaching me about $PSDefaultParameterValues. In short, the Cloud Shell team have set you up for success by defaulting to the CurrentUser scope when installing modules Smile

Comments (0)

Skip to main content