19.4. Tab Completion
Tab completion is available to you when using the get-childitem cmdlet and other cmdlets. As you can see in Figure 19-19, when I run the command:
get-childitem [pw]* |
where-object {$_.Mode -match "d"}
in the root directory of a Windows XP machine's hard disk, several folders are displayed, including the Windows folder and the Pro PowerShell folder.
Figure 19.19. Figure 19-19
If you type
cd wi
then press the Tab key, the name of the single matching folder C:\Windows is completed for you.
Similarly, if you delete the preceding and type
cd Pro
then press the Tab key twice (since I still have a Pro Monad folder) the command changes cycles to
cd 'Pro PowerShell'
with the paired apostrophes intelligently added for you. If you intended to change the folder to the C:\Program Files folder, press Tab twice more and the command changes to:
cd 'Program Files'
Thus, Windows PowerShell will complete folder names for you. If there is ambiguity, pressing the Tab key additional times allows you to cycle through the matching options.
NOTE
Be aware that in PowerShell 1.0 that tab completion for set-location or its cd alias also cycles through filenames. You can't set the location to be a file. I assume that this behavior will be corrected in a future version of PowerShell.
Tab completion also works for each step of a multistep change in location. For example, to move to the ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access