PowerShell TabExtension - Part 5 PowerTab 0.9
I made some mayor updates to my PowerShell TabExtension Function PowerTab , most important are
DoubleClick support and a TabItemSelector using RawUI to create a selectable and scollable list of the TabCompletion possibilities, offering a kind of Consolebased intellisense GUI,
That adds a lot of extra functionalty and added value to the function. So I made a new version PowerTab 0.9 In this 5th part of the series I will descibe the added functionality and changes from the former version : PowerTab 0.8 PowerShell TabExtension - Part 4 Updates from 0.72 .
For more information about the PowerTab suite and the rest of the series see also the PowerTab Overview Page where you allways can find the latest version for download, or you can use the TagList PowerTab to get a list of all former posts about PowerTab.
Updates from Version 0.8
- Native Command Expansion (.EXE .COM.) with !
- DoubleClick support
- The TabItemSelector Output is now Extendable
- Alias Completion uses DoubleTab now
- Console TabItemSelector using RawUI to create Consolebased intellisense GUI
- some other smaller fixes
I did see the following entry on Lee Holmes blog : http://www.leeholmes.com/blog/AddingDoubleTapTabCompletionToPowerShell.aspx , about adding DoubleClick support to TabCompletion. I was not very impressed by the functionality showed in the example, but I loved the idea of using DoubleTab to do alternate completion and did see the great possibilities that it could offer for my PowerShell TabExtension extension function PowerTab.
And when I did see how simple it was to implement the DoubleTab functionality I really got that *Doink* feeling, why didn't I think of that before, the actual change needed to enable DoubleTab support in my TabExpansion was this :
# Detect DoubleTab
Start-Sleep -m 400
$DoubleTab = ($host.UI.RawUI.KeyAvailable)
That was basicly all !!
Now I could check this $doubleTab variable within my tabcompletion function and react different depending on the state of $doubleTab.
As the expansion of aliases sometimes conflicts with FilePath expansion, for example say your in the sysinternal folder and, as most of the tools start with PS, want to tabcomplete on that, but PS is an alias hence you will get Get-Process.
With DoubleTab support I could and did fix that now by only expanding on aliases.
More than that, as I allready changed my own version of PowerTab to support external handling of the output, to enable me to switch between "normal" tabcompletion and using Aaron Lerch: PowerTab Powershell Intellisense (more about that in a later post) by setting a variable, now with DoubleClick Support I could enble them at the same time with only minor changes using :
[Tab] for normal tabcompletion
[DoubleTab] for Intelisense
But when I discussed my DoubleTab support on IRC with xaegr , the value of consolebased handling came up and I made an Out-ConsoleList function, for PowerTab to show a list with select and scoll capabilities, like intelitype without Forms, only the console using RawUI :
I added this function as a DoubleClick Handler to all the other PowerTab TabExpansion functionality, except alias and custom expansion as a changed them to use DoubleClick for normal invokation as mentioned before and there is nothing to select anyone as only one instance is returned.
So now you can use DoubleClick to get a list of options to choose from, making them much more visual by placing them in a list and enable you to view and select them using the Arrow UP and DOWN key's, adding a lot of extra value to PowerTab.
this added "Console based intellisense" for PowerShell in this new version looks like this :
WhenEver Possible the List will be Displayed below the current line at the place of the Cursor, if the list does not fit below, but does fit above it will be placed above, If the list does not fit Below or above it will be placed where the most lines are available and fill them all, as you can see below :
PoSH>
PoSH> Get-Acl
PoSH> get-Admin
PoSH> Get-Alias
PoSH> Get-AuthenticodeSignature
PoSH> get-buffer
PoSH> Get-ChildItem
PoSH> Get-Command
PoSH> Get-ComputerManagement
PoSH> Get-Content
PoSH> Get-Credential
PoSH> Get-Culture
PoSH> Get-Date
PoSH> Get-EventLog
PoSH> [ 1 of 36 ]
PoSH> get-
You can see above that you can use it with WMI classes and Cmdlets but you can use at for almost all functionality, try for example :
[Math]::[DoubleTab]
$h[DoubleTab]
$host.[DoubleTab]
[s[DoubleTab].[DoubleTab]
get-help about_[DoubleTab]
$global:[DoubleTab]
In the Console Output below I show a another nice usage example showing how you can make great use of this, combined with other PowerTab functionality, to CD to an UNC path using a list of computers to select from and than list the shares and select one. Also I will show how to get a list with all native commands starting with net by using the new ! native Command completion combined with DoubleTab:
I use DoubleTab to list all add functions for TabExpansion, then add localHost to the list, also added computers discovered by netView.
After I show that after that can just type
cd \\[DoubleTab]
To select a Computer, type
\\[DoubleTab]
to get a list of all shares (as a normal user and also hidden shares), to select from.
PoSH> add-tab
PoSH>
PoSH> add-tabExpansion
PoSH> add-TabExpansionComputersNetView
PoSH> add-TabExpansionComputersOU
PoSH> [ 1 of 3 ]
PoSH> add-tabExpansion Localhost Localhost Computer
Filter Text Type
------ ---- ----
Localhost Localhost Computer
PoSH> add-TabExpansionComputersNetView
Filter Text Type
------ ---- ----
MowServer1 MowServer1 Computer
MowServer2 MowServer2 Computer
MowServer3 MowServer3 Computer
PoSH> \\
PoSH>
PoSH> \\Localhost
PoSH> \\MowServer1
PoSH> \\MowServer2
PoSH> \\MowServer3
PoSH> [ 1 of 2 ]
PoSH> \\Localhost\
PoSH>
PoSH> \\Localhost\ADMIN$
PoSH> \\Localhost\C$
PoSH> \\Localhost\IPC$
PoSH> \\Localhost\Posh
PoSH> [ 1 of 4 ]
PoSH>
PoSH> net.exe
PoSH> net1.exe
PoSH> netbtugc.exe
PoSH> netcfg.exe
PoSH> netiougc.exe
PoSH> Netplwiz.exe
PoSH> NetProj.exe
PoSH> netsh.exe
PoSH> NETSTAT.EXE
PoSH> [ 1 of 9 ]
PoSH> net!
You can from the last example how easy this makes to find and start programs in your path, but there are a lot more places this adds a lot off added value, see former posts for more information about other PowerTab Functionality.
*Update* If you want to see some extra examples of PowerTab 0.9 DoubleTab usage, Xaegr posted some more screendumps here : http://xaegr.livejournal.com/25934.html (In Google English)
If you are installing for the first time you can just run PowerTabSetup.Ps1 from the installation directory ( the folder you extracted the files in ) to setup PowerTab 0.9. ( for more info about the PowerTabSetup.ps1 script and the setup process see : PowerTab 0.72 PowerShell TabExtension - Part 1 Installation )
*Note* If you are upgrading, take care the setup will not remove old configuration from profile you need to remove this manualy, see also readme file :
Place files in directory and Run the PowerTabSetup.ps1 setup routine, if upgrading from older version you might need to clean up old config from profile
or to upgrade manualy, replace files and add following line to Profile to be able to use RawUI Tabresultselection :
. 'C:\PowerShell\PowerTab\Out-ConsoleList.ps1' # Used for RawUi ConsoleList
I will post PowerTab 0.9 on the PowerTab Overview Page , where you can always find the latest version.
Enjoy,
Greetings /\/\o\/\/