11.5. Tab Expansion: How Command Completion Works

Many UNIX shells and cmd.exe have provided file name completion for quite some time. Again, they did it in a way that reminds me of Henry Ford's saying about Model T car colors—customers can have a car painted any color, so long as it is black. PowerShell goes beyond the uncustomizable completion mechanisms of other shells by using the same approach as with prompt strings—it does its customizations through a global function that can extend tab completion. By default, in addition to file names, hitting the Tab key will complete cmdlet names, cmdlet parameters, variable names, and object properties. We can extend that by defining a global function and naming it TabExpansion. Let's first see how ...

Get Pro Windows PowerShell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.