Formatting tab argument completion powershell -
i'm using tabexpansion2 in powershell 3 , when tab complete argument brings string want wrapped in syntax don't want.
for instance when hit tab after -binname
:
use-bin -binname @{name=5.0}
what need is:
use-bin -binname 5.0
i'm using script: https://www.powershellgallery.com/packages/powershellcookbook/1.3.6/content/tabexpansion.ps1
with these adjusted options:
$options["customargumentcompleters"] = @{ "binname" = {get-childitem -path $global:th_bindir | select-object name} "dbname" = {get-childitem -path $global:th_dbdir\rt5.7\ | select-object name} "patchsubdir" ={get-childitem -path $global:th_bindir\patches\ | select-object name} "hmisubdir" = {get-childitem -path $global:th_hmidir | select-object name} "modulescript" = {get-childitem -path $global:th_modpaths | select-object name} "items" = {"bins", "databases", "modules"} }
thanks!
i not familiar tabexpansion issue returning objects name
properties. want return strings.
$options["customargumentcompleters"] = @{ "binname" = {get-childitem -path $global:th_bindir | select-object -expandproperty name} "dbname" = {get-childitem -path $global:th_dbdir\rt5.7\ | select-object -expandproperty name} "patchsubdir" ={get-childitem -path $global:th_bindir\patches\ | select-object -expandproperty name} "hmisubdir" = {get-childitem -path $global:th_hmidir | select-object -expandproperty name} "modulescript" = {get-childitem -path $global:th_modpaths | select-object -expandproperty name} "items" = {"bins", "databases", "modules"} }
since using 3.0 more terse , accomplish same thing.
$options["customargumentcompleters"] = @{ "binname" = {(get-childitem -path $global:th_bindir).name} "dbname" = {(get-childitem -path $global:th_dbdir\rt5.7\).name} "patchsubdir" ={(get-childitem -path $global:th_bindir\patches\).name} "hmisubdir" = {(get-childitem -path $global:th_hmidir).name} "modulescript" = {(get-childitem -path $global:th_modpaths).name} "items" = {"bins", "databases", "modules"} }
both solutions work expanding strings of single property name
.
Comments
Post a Comment