Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - tab and variable

Reply
 
Old 10-17-2006   #1 (permalink)
hn


 
 

tab and variable

I'm trying to use tab together with variable, e.g.:
by typing $pshome<enter>, i have
c:\windows\system32\windowspowershell\v1.0

i would expect
$pshome\..\<tab> would resolve to
c:\windows\system32\windowspowershell\v1.0\..\ OR
c:\windows\system32\windowspowershell\v1.0\

but it does not, it resolves somewhere to
c:\document and settings\username\$pshome\..\...

am i using it right? Thanks!

My System SpecsSystem Spec
Old 10-17-2006   #2 (permalink)
Andrew Webb


 
 

RE: tab and variable

<tab> works off the contents of your current location. Expecting it to pay
attention to the current contents of PowerShell variables is probably a bit
much. I think it's really impressive that you can do this, though:-
cd hkcu: <enter>
cd <tab>, <tab>, <tab>, <tab>, <tab>,
and have it iterate through the contents of the HKCU drive.

I would say that the PowerShell team have gone far enough integrating with
the current Cmd.exe-style window, and in future releases it would be nice to
see them using their own windowed environment. What they have done thus far
(e.g. the example above) is damn impressive as it is.

Andrew Webb
My System SpecsSystem Spec
Old 10-17-2006   #3 (permalink)
hn


 
 

RE: tab and variable

I think by saying '<tab> works off the contents of your current location' is
correct, but the fact is the PS' tab-completion is worth more than that, I
believe you can enter:
hkcu:<tab>
without being in hkcu drive.

So PS is already pay attention to previous token, so by substition env.
variable, I don't know, maybe you are right, 'a bit too much'

"Andrew Webb" wrote:

> <tab> works off the contents of your current location. Expecting it to pay
> attention to the current contents of PowerShell variables is probably a bit
> much. I think it's really impressive that you can do this, though:-
> cd hkcu: <enter>
> cd <tab>, <tab>, <tab>, <tab>, <tab>,
> and have it iterate through the contents of the HKCU drive.
>
> I would say that the PowerShell team have gone far enough integrating with
> the current Cmd.exe-style window, and in future releases it would be nice to
> see them using their own windowed environment. What they have done thus far
> (e.g. the example above) is damn impressive as it is.
>
> Andrew Webb

My System SpecsSystem Spec
Old 10-17-2006   #4 (permalink)
Andrew Webb


 
 

RE: tab and variable

> I think by saying '<tab> works off the contents of your current location' is
> correct, but the fact is the PS' tab-completion is worth more than that, I
> believe you can enter:
> hkcu:<tab>
> without being in hkcu drive.


You're right! Even more impressive than I thought.

Try this:
$e<tab><tab><tab>

It will iterate through the current list of variables, listing those that
begin with 'e'. This is what it will do with variables, rather than examine
their contents - which I think answers your original question.


My System SpecsSystem Spec
Old 10-17-2006   #5 (permalink)
hn


 
 

RE: tab and variable

not really answer to my question, my question is why
$pshome\..\
does not expand to
c:\windows\system32\windowspowershell\

"Andrew Webb" wrote:

> > I think by saying '<tab> works off the contents of your current location' is
> > correct, but the fact is the PS' tab-completion is worth more than that, I
> > believe you can enter:
> > hkcu:<tab>
> > without being in hkcu drive.

>
> You're right! Even more impressive than I thought.
>
> Try this:
> $e<tab><tab><tab>
>
> It will iterate through the current list of variables, listing those that
> begin with 'e'. This is what it will do with variables, rather than examine
> their contents - which I think answers your original question.
>
>

My System SpecsSystem Spec
Old 10-17-2006   #6 (permalink)
Sung M Kim


 
 

Re: tab and variable

hn wrote:
> not really answer to my question, my question is why
> $pshome\..\
> does not expand to
> c:\windows\system32\windowspowershell\


It is because expanding the "value" of parameter is not implemented in
the TabExpanion function( located in function:TabExpansion, and to see
the definition of the function try, (ls
function:TabExpansion).definition ).

My System SpecsSystem Spec
Old 10-17-2006   #7 (permalink)
Adam Milazzo


 
 

Re: tab and variable

hn wrote:
> I'm trying to use tab together with variable, e.g.:
> by typing $pshome<enter>, i have
> c:\windows\system32\windowspowershell\v1.0
>
> i would expect
> $pshome\..\<tab> would resolve to
> c:\windows\system32\windowspowershell\v1.0\..\ OR
> c:\windows\system32\windowspowershell\v1.0\
>
> but it does not, it resolves somewhere to
> c:\document and settings\username\$pshome\..\...
>
> am i using it right? Thanks!


Unfortunately PowerShell doesn't support this out of the box. I already
filed a bug about it...

But you can implement it yourself by modifying the definition of the
TabExpansion function. Or, rather, you can use other people's tab
expansion scripts. I know I've seen one posted to this newsgroup that
does variable expansion and a number of other things...

Perhaps somebody can reply with a link to the script, or perhaps you can
post a new thread asking about the community's tab expansion addons.
My System SpecsSystem Spec
Old 10-18-2006   #8 (permalink)
Bruce Payette [MSFT]


 
 

Re: tab and variable

Correct - the tab completion code for filenames isn't expanding variables in
paths. It is possible to modify the TabCompletion function to do this with
some work. Tab-completion in V1 is very much a glass-half full experience
:-)

-bruce

--
Bruce Payette [MSFT]
Windows PowerShell Technical Lead
Microsoft Corporation
This posting is provided "AS IS" with no warranties, and confers no rights.
Visit the Windows PowerShell Team blog at:
http://blogs.msdn.com/PowerShell
Visit the Windows PowerShell ScriptCenter at:
http://www.microsoft.com/technet/scr.../hubs/msh.mspx
My book: http://manning.com/powershell


"Sung M Kim" <DontBotherMeWithSpam@gmail.com> wrote in message
news:1161104935.391170.273890@i42g2000cwa.googlegroups.com...
> hn wrote:
>> not really answer to my question, my question is why
>> $pshome\..\
>> does not expand to
>> c:\windows\system32\windowspowershell\

>
> It is because expanding the "value" of parameter is not implemented in
> the TabExpanion function( located in function:TabExpansion, and to see
> the definition of the function try, (ls
> function:TabExpansion).definition ).
>



My System SpecsSystem Spec
Old 10-20-2006   #9 (permalink)
/\\/\\o\\/\\/ [MVP]


 
 

Re: tab and variable

I have a series about TabExpansion on my blog :
the latestversion is :

http://mow001.blogspot.com/2006/10/p...on-part-5.html

It realy adds a lot to the TabCompletion like (WMI,alias, history, functions
etc. (even GUI form support for selecting from a list, and custom
completion) and much more.
This last version needs some preparement and getting used to, as it uses a
DataBase to work, but after that is realy powerfull I think

The former versions works as is, and might be more easy to start with :

http://mow001.blogspot.com/2006/06/p...on-part-4.html

on Codeplex :

http://www.codeplex.com/Wiki/View.as...tName=PsObject

Enjoy,

Greetings /\/\o\/\/

"Adam Milazzo" <adamm@san.rr.com> wrote in message
news:uGNVlri8GHA.4476@TK2MSFTNGP04.phx.gbl...
> hn wrote:
>> I'm trying to use tab together with variable, e.g.:
>> by typing $pshome<enter>, i have
>> c:\windows\system32\windowspowershell\v1.0
>>
>> i would expect $pshome\..\<tab> would resolve to
>> c:\windows\system32\windowspowershell\v1.0\..\ OR
>> c:\windows\system32\windowspowershell\v1.0\
>>
>> but it does not, it resolves somewhere to
>> c:\document and settings\username\$pshome\..\...
>>
>> am i using it right? Thanks!

>
> Unfortunately PowerShell doesn't support this out of the box. I already
> filed a bug about it...
>
> But you can implement it yourself by modifying the definition of the
> TabExpansion function. Or, rather, you can use other people's tab
> expansion scripts. I know I've seen one posted to this newsgroup that does
> variable expansion and a number of other things...
>
> Perhaps somebody can reply with a link to the script, or perhaps you can
> post a new thread asking about the community's tab expansion addons.



My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
$Variable Is In {1,2,3,4} PowerShell
Ren file with variable PowerShell
Import-CSV from Web/Variable PowerShell
Set-Variable PowerShell
How can I ensure that a variable is a built-in powershell variable? PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46