PowerShell TabExtension - Part 8 Tip Use Custom Expansion to switch help Modes fast
By default PowerShell only displays a summary of the Help available, If we want more info we can use a parameter on get=help.
This is handy most of the times, but the problem is that I usually get help by using -? behind the command.
So say I type :
Import-Csv -?
but I want more information now I can not use my command buffer to scroll up just to change the parameter because I need to change the command
Get-Help Import-Csv -Full
You see that I need to put text in front and behind the command. a lot of typing, and not really quick and handy.
But with PowerTab 0.91 (see PowerShell TabExtension - Part 7 PowerTab 0.91 Released ) we can easy fix this :
add-tabExpansion h 'Get-help $^ -Full'
add-tabExpansion h 'Get-help $^ -Detailed'
add-tabExpansion h 'Get-help $^ -Examples'
Save-tabExpansion
to invoke Custom Tabcompletion aliases we type a ^ behind it with PowerTab 0.91 , so now we only need to type h^[tab][enter] to get full help or select one of the other modes.
How does this work ?
As $^ in PowerShell contains the first word of the last line, in case of Import-Csv -? the cmdletname we need the get-help on, as we did put this in our Custom Tabcompletion we can now tabcomplete on it when we hit enter the $^ variable get's resolved to the name of the CmdLet we did -? on before,
So from now we can just use h^[tab] to get the other modes of help for the cmdlet that was the first command on the last line ( in this case the command we did the -? on ):
Now don't forget !
to save this work for later sessions we need to save it :
Save-tabExpansion
And we are all done, and have this shortcut handy at all times !
You see using Tabcompletion for inserting custom code Snippets by aliases like this can be very powerful, see also enum examples in last post (PowerShell TabExtension - Part 7 PowerTab 0.91 Released ) , you can create and organize the codesnippets that you use often, and keep them ready at your fingertips
What handy other snippets can you come up with using PowerTab 0.91 Custom Tab Expansion ?
If you have some nice one's, or other Powertab tip's or experiences please let me know ;-)
Enjoy,
Greetings /\/\o\/\/