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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.